Skip to content
Permalink
Browse files
[FLINK-27672][tests][table] Migrate flink-table-common to JUnit5
  • Loading branch information
snuyanzin committed May 20, 2022
1 parent d993232 commit f1b4742b87de6175289539ca3c83c4e33ba4e825
Showing 61 changed files with 879 additions and 1,125 deletions.
@@ -85,6 +85,12 @@ under the License.
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<excludes>
<!-- test-jar is still used by JUnit4 modules -->
<exclude>META-INF/services/org.junit.jupiter.api.extension.Extension</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
@@ -23,7 +23,7 @@
import org.apache.flink.table.api.constraints.UniqueConstraint;
import org.apache.flink.table.types.DataType;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
@@ -34,15 +34,15 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/** Tests for {@link TableSchema}. */
public class TableSchemaTest {
class TableSchemaTest {

private static final String WATERMARK_EXPRESSION = "localtimestamp";
private static final String WATERMARK_EXPRESSION_TS_LTZ = "now()";
private static final DataType WATERMARK_DATATYPE = DataTypes.TIMESTAMP(3);
private static final DataType WATERMARK_TS_LTZ_DATATYPE = DataTypes.TIMESTAMP_LTZ(3);

@Test
public void testTableSchema() {
void testTableSchema() {
TableSchema schema =
TableSchema.builder()
.add(TableColumn.physical("f0", DataTypes.BIGINT()))
@@ -89,7 +89,7 @@ public void testTableSchema() {
}

@Test
public void testWatermarkOnTimestampLtz() {
void testWatermarkOnTimestampLtz() {
TableSchema tableSchema =
TableSchema.builder()
.field("f0", DataTypes.TIMESTAMP())
@@ -111,7 +111,7 @@ public void testWatermarkOnTimestampLtz() {
}

@Test
public void testPersistedRowDataType() {
void testPersistedRowDataType() {
final TableSchema schema =
TableSchema.builder()
.add(TableColumn.physical("f0", DataTypes.BIGINT()))
@@ -134,7 +134,7 @@ public void testPersistedRowDataType() {
}

@Test
public void testPhysicalRowDataType() {
void testPhysicalRowDataType() {
final TableSchema schema =
TableSchema.builder()
.add(TableColumn.physical("f0", DataTypes.BIGINT()))
@@ -155,7 +155,7 @@ public void testPhysicalRowDataType() {
}

@Test
public void testRowDataType() {
void testRowDataType() {
final TableSchema schema =
TableSchema.builder()
.add(TableColumn.physical("f0", DataTypes.BIGINT()))
@@ -180,7 +180,7 @@ public void testRowDataType() {
}

@Test
public void testWatermarkOnDifferentFields() {
void testWatermarkOnDifferentFields() {
// column_name, column_type, exception_msg
List<Tuple3<String, DataType, String>> testData = new ArrayList<>();
testData.add(Tuple3.of("a", DataTypes.BIGINT(), "but is of type 'BIGINT'"));
@@ -215,7 +215,7 @@ public void testWatermarkOnDifferentFields() {
}

@Test
public void testWatermarkOnNestedField() {
void testWatermarkOnNestedField() {
TableSchema schema =
TableSchema.builder()
.field("f0", DataTypes.BIGINT())
@@ -239,7 +239,7 @@ public void testWatermarkOnNestedField() {
}

@Test
public void testWatermarkOnNonExistedField() {
void testWatermarkOnNonExistedField() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -258,7 +258,7 @@ public void testWatermarkOnNonExistedField() {
}

@Test
public void testMultipleWatermarks() {
void testMultipleWatermarks() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -278,7 +278,7 @@ public void testMultipleWatermarks() {
}

@Test
public void testDifferentWatermarkStrategyOutputTypes() {
void testDifferentWatermarkStrategyOutputTypes() {
List<Tuple2<DataType, String>> testData = new ArrayList<>();
testData.add(Tuple2.of(DataTypes.BIGINT(), "but is of type 'BIGINT'"));
testData.add(Tuple2.of(DataTypes.STRING(), "but is of type 'STRING'"));
@@ -313,7 +313,7 @@ public void testDifferentWatermarkStrategyOutputTypes() {
CONSTRAINTS TESTS
*/
@Test
public void testPrimaryKeyPrinting() {
void testPrimaryKeyPrinting() {
TableSchema schema =
TableSchema.builder()
.field("f0", DataTypes.BIGINT().notNull())
@@ -332,7 +332,7 @@ public void testPrimaryKeyPrinting() {
}

@Test
public void testPrimaryKeyColumnsIndices() {
void testPrimaryKeyColumnsIndices() {
TableSchema schema =
TableSchema.builder()
.field("f0", DataTypes.BIGINT().notNull())
@@ -347,7 +347,7 @@ public void testPrimaryKeyColumnsIndices() {
}

@Test
public void testPrimaryKeyLazilyDefinedColumns() {
void testPrimaryKeyLazilyDefinedColumns() {
TableSchema schema =
TableSchema.builder()
.field("f0", DataTypes.BIGINT().notNull())
@@ -362,7 +362,7 @@ public void testPrimaryKeyLazilyDefinedColumns() {
}

@Test
public void testPrimaryKeyNoColumn() {
void testPrimaryKeyNoColumn() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -374,7 +374,7 @@ public void testPrimaryKeyNoColumn() {
}

@Test
public void testPrimaryKeyNullableColumn() {
void testPrimaryKeyNullableColumn() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -386,7 +386,7 @@ public void testPrimaryKeyNullableColumn() {
}

@Test
public void testPrimaryKeyGeneratedColumn() {
void testPrimaryKeyGeneratedColumn() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -399,7 +399,7 @@ public void testPrimaryKeyGeneratedColumn() {
}

@Test
public void testPrimaryKeyNameMustNotBeNull() {
void testPrimaryKeyNameMustNotBeNull() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -411,7 +411,7 @@ public void testPrimaryKeyNameMustNotBeNull() {
}

@Test
public void testPrimaryKeyNameMustNotBeEmpty() {
void testPrimaryKeyNameMustNotBeEmpty() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -423,7 +423,7 @@ public void testPrimaryKeyNameMustNotBeEmpty() {
}

@Test
public void testPrimaryKeyNoColumns() {
void testPrimaryKeyNoColumns() {
assertThatThrownBy(
() ->
TableSchema.builder()
@@ -18,18 +18,18 @@

package org.apache.flink.table.api.constraints;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

/** Tests for {@link UniqueConstraint}. */
public class UniqueConstraintTest {
class UniqueConstraintTest {

@Test
public void testCreatingPrimaryKey() {
void testCreatingPrimaryKey() {
String keyName = "pk";
List<String> columns = Collections.singletonList("f0");
UniqueConstraint primaryKey = UniqueConstraint.primaryKey(keyName, columns);
@@ -30,7 +30,7 @@
import org.apache.flink.table.data.columnar.vector.heap.HeapTimestampVector;
import org.apache.flink.table.data.columnar.vector.writable.WritableColumnVector;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;
import java.util.stream.IntStream;
@@ -45,12 +45,12 @@
import static org.assertj.core.api.Assertions.assertThat;

/** Test {@link ColumnVector}. */
public class ColumnVectorTest {
class ColumnVectorTest {

private static final int SIZE = 10;

@Test
public void testNulls() {
void testNulls() {
HeapBooleanVector vector = new HeapBooleanVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -83,7 +83,7 @@ public void testNulls() {
}

@Test
public void testBoolean() {
void testBoolean() {
HeapBooleanVector vector = new HeapBooleanVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -100,7 +100,7 @@ public void testBoolean() {
}

@Test
public void testByte() {
void testByte() {
HeapByteVector vector = new HeapByteVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -123,7 +123,7 @@ public void testByte() {
}

@Test
public void testShort() {
void testShort() {
HeapShortVector vector = new HeapShortVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -146,7 +146,7 @@ public void testShort() {
}

@Test
public void testInt() {
void testInt() {
HeapIntVector vector = new HeapIntVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -184,7 +184,7 @@ public void testInt() {
}

@Test
public void testLong() {
void testLong() {
HeapLongVector vector = new HeapLongVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -216,7 +216,7 @@ public void testLong() {
}

@Test
public void testFloat() {
void testFloat() {
HeapFloatVector vector = new HeapFloatVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -253,7 +253,7 @@ public void testFloat() {
}

@Test
public void testDouble() {
void testDouble() {
HeapDoubleVector vector = new HeapDoubleVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -292,7 +292,7 @@ private byte[] produceBytes(int i) {
}

@Test
public void testBytes() {
void testBytes() {
HeapBytesVector vector = new HeapBytesVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -326,7 +326,7 @@ public void testBytes() {
}

@Test
public void testTimestamp() {
void testTimestamp() {
HeapTimestampVector vector = new HeapTimestampVector(SIZE);

for (int i = 0; i < SIZE; i++) {
@@ -353,7 +353,7 @@ public void testTimestamp() {
}

@Test
public void testReserveDictIds() {
void testReserveDictIds() {
HeapIntVector vector = new HeapIntVector(SIZE);
assertThat(vector.reserveDictionaryIds(2).vector.length).isGreaterThanOrEqualTo(2);
assertThat(vector.reserveDictionaryIds(5).vector.length).isGreaterThanOrEqualTo(5);
@@ -33,7 +33,7 @@
import org.apache.flink.table.data.columnar.vector.heap.HeapShortVector;
import org.apache.flink.table.utils.DateTimeUtils;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -42,13 +42,13 @@
import static org.assertj.core.api.Assertions.assertThat;

/** Test {@link VectorizedColumnBatch}. */
public class VectorizedColumnBatchTest {
class VectorizedColumnBatchTest {

private static final int VECTOR_SIZE = 1024;
private static final int ARRAY_SIZE = 3;

@Test
public void testTyped() throws IOException {
void testTyped() throws IOException {
HeapBooleanVector col0 = new HeapBooleanVector(VECTOR_SIZE);
for (int i = 0; i < VECTOR_SIZE; i++) {
col0.vector[i] = i % 2 == 0;
@@ -256,7 +256,7 @@ public ArrayData getArray(int i) {
}

@Test
public void testNull() {
void testNull() {
// all null
HeapIntVector col0 = new HeapIntVector(VECTOR_SIZE);
for (int i = 0; i < VECTOR_SIZE; i++) {
@@ -287,7 +287,7 @@ public void testNull() {
}

@Test
public void testDictionary() {
void testDictionary() {
// all null
HeapIntVector col = new HeapIntVector(VECTOR_SIZE);
Integer[] dict = new Integer[2];

0 comments on commit f1b4742

Please sign in to comment.