Skip to content
Permalink
Browse files
[hotfix][table][tests] Clean-up tests and update to assertJ
  • Loading branch information
matriv authored and twalthr committed May 9, 2022
1 parent 87046b2 commit 8a7a613909ae7c43f2839d11bc0ad1640329d1b0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 27 deletions.
@@ -140,7 +140,7 @@ public void testCompleteStatement() {
assertThat(executor.completeStatement(sessionId, "SELECT * FROM TableNumber1 WH", 29))
.isEqualTo(expectedClause);

final List<String> expectedField = Arrays.asList("IntegerField1");
final List<String> expectedField = Collections.singletonList("IntegerField1");
assertThat(
executor.completeStatement(
sessionId, "SELECT * FROM TableNumber1 WHERE Inte", 37))
@@ -23,9 +23,8 @@ import org.apache.flink.table.functions.ScalarFunction
import org.apache.flink.table.types.extraction.TypeInferenceExtractorTest.TestSpec
import org.apache.flink.table.types.inference.{ArgumentTypeStrategy, InputTypeStrategies, TypeStrategies}

import org.hamcrest.CoreMatchers.equalTo
import org.assertj.core.api.AssertionsForClassTypes.assertThat
import org.junit.{Rule, Test}
import org.junit.Assert.assertThat
import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@@ -46,27 +45,24 @@ class TypeInferenceExtractorScalaTest(testSpec: TestSpec) {
@Test
def testArgumentNames(): Unit = {
if (testSpec.expectedArgumentNames != null) {
assertThat(
testSpec.typeInferenceExtraction.get.getNamedArguments,
equalTo(Optional.of(testSpec.expectedArgumentNames)))
assertThat(testSpec.typeInferenceExtraction.get.getNamedArguments)
.isEqualTo(Optional.of(testSpec.expectedArgumentNames))
}
}

@Test
def testArgumentTypes(): Unit = {
if (testSpec.expectedArgumentTypes != null) {
assertThat(
testSpec.typeInferenceExtraction.get.getTypedArguments,
equalTo(Optional.of(testSpec.expectedArgumentTypes)))
assertThat(testSpec.typeInferenceExtraction.get.getTypedArguments)
.isEqualTo(Optional.of(testSpec.expectedArgumentTypes))
}
}

@Test
def testOutputTypeStrategy(): Unit = {
if (!testSpec.expectedOutputStrategies.isEmpty) {
assertThat(
testSpec.typeInferenceExtraction.get.getOutputTypeStrategy,
equalTo(TypeStrategies.mapping(testSpec.expectedOutputStrategies)))
assertThat(testSpec.typeInferenceExtraction.get.getOutputTypeStrategy)
.isEqualTo(TypeStrategies.mapping(testSpec.expectedOutputStrategies))
}
}
}
@@ -83,7 +83,6 @@ public void open(InitializationContext context) throws Exception {
initFieldParsers();
}

@SuppressWarnings("unchecked")
@Override
public RowData deserialize(byte[] message) throws IOException {
GenericRowData row = new GenericRowData(physicalFieldCount);
@@ -1220,7 +1220,6 @@ private static class CastTestSpecBuilder {
private final List<Object> columnData = new ArrayList<>();
private final List<DataType> columnTypes = new ArrayList<>();
private final List<Object> expectedValues = new ArrayList<>();
private final List<Class<? extends Throwable>> expectedFailureClasses = new ArrayList<>();
private final List<TestType> testTypes = new ArrayList<>();

private enum TestType {
@@ -185,7 +185,7 @@ public class DiffRepository {
* share the same diff-repository: if the repository gets loaded once per test case, then only
* one diff is recorded.
*/
private static final Map<Class, DiffRepository> MAP_CLASS_TO_REPOSITORY = new HashMap<>();
private static final Map<Class<?>, DiffRepository> MAP_CLASS_TO_REPOSITORY = new HashMap<>();

// ~ Instance fields --------------------------------------------------------

@@ -599,9 +599,6 @@ private static void writeNode(Node node, XmlOutput out) {
Node child = childNodes.item(i);
writeNode(child, out);
}

// writeNode(((Document) node).getDocumentElement(),
// out);
break;

case Node.ELEMENT_NODE:
@@ -678,7 +675,7 @@ private static boolean isWhitespace(String text) {
* @param clazz Test case class
* @return The diff repository shared between test cases in this class.
*/
public static DiffRepository lookup(Class clazz) {
public static DiffRepository lookup(Class<?> clazz) {
return lookup(clazz, null);
}

@@ -689,7 +686,7 @@ public static DiffRepository lookup(Class clazz) {
* @param baseRepository Base class of test class
* @return The diff repository shared between test cases in this class.
*/
public static DiffRepository lookup(Class clazz, DiffRepository baseRepository) {
public static DiffRepository lookup(Class<?> clazz, DiffRepository baseRepository) {
return lookup(clazz, baseRepository, null);
}

@@ -716,7 +713,7 @@ public static DiffRepository lookup(Class clazz, DiffRepository baseRepository)
* @return The diff repository shared between test cases in this class.
*/
public static synchronized DiffRepository lookup(
Class clazz, DiffRepository baseRepository, Filter filter) {
Class<?> clazz, DiffRepository baseRepository, Filter filter) {
DiffRepository diffRepository = MAP_CLASS_TO_REPOSITORY.get(clazz);
if (diffRepository == null) {
final URL refFile = findFile(clazz, ".xml");
@@ -41,8 +41,4 @@ public static JsonNode setFlinkVersion(JsonNode target, FlinkVersion flinkVersio
return ((ObjectNode) target)
.set("flinkVersion", OBJECT_MAPPER_INSTANCE.valueToTree(flinkVersion.toString()));
}

public static JsonNode clearFlinkVersion(JsonNode target) {
return ((ObjectNode) target).remove("flinkVersion");
}
}
@@ -19,7 +19,6 @@
package org.apache.flink.table.planner.utils;

import org.apache.flink.table.api.Schema;
import org.apache.flink.table.api.TableSchema;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;

@@ -68,7 +67,7 @@ public class OperationMatchers {
*
* @param nestedMatchers additional matchers that must match
* @see #withOptions(MapEntry[])
* @see #withSchema(TableSchema)
* @see #withSchema(Schema)
* @see #partitionedBy(String...)
*/
@SafeVarargs

0 comments on commit 8a7a613

Please sign in to comment.