asolimando commented on a change in pull request #139: URL: https://github.com/apache/calcite-avatica/pull/139#discussion_r580496281
########## File path: core/src/test/java/org/apache/calcite/avatica/util/UtilTestCommon.java ########## @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.avatica.util; + +import org.apache.calcite.avatica.ColumnMetaData; +import org.apache.calcite.avatica.MetaImpl; + +import java.sql.Array; +import java.sql.ResultSet; +import java.util.Collections; +import java.util.List; +import java.util.function.BiFunction; +import java.util.stream.Collectors; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Common auxiliary methods for tests in util package. + */ +public class UtilTestCommon { + + private UtilTestCommon() { + // private constructor + } + + static void assertResultSetFromArray(ColumnMetaData.ScalarType arrayComponentType, Review comment: I have tried to split the methods (as discussed in another comment), now `static void assertRowsValuesMatchCursorContentViaArrayAccessor` mainly iterates over the cursor by creating an array accessor. I have introduced two additional helper classes `ColumnMetadataTestUtils` (to simplify the handling of `ColumnMetadata`, pretty repetitive and error prone, and it opens the door to support more types via JUnit Parameterized class later on), and `CursorTestUtils` (to help creating Array/List/ArrayImpl-based cursors more easily). Validation is delegated to the concrete implementations of the `Validator` interface, which can be as simple as a lambda if you don't need much like in the tests I have added. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
