Test utilities for Apache Flink's Table API and SQL ecosystem enabling robust testing of table operations and data transformations.
—
Fluent assertions for Flink's internal data structures including RowData, ArrayData, MapData, and StringData. These assertions provide comprehensive validation capabilities with automatic type conversion between internal and external representations.
Assertions for Flink's internal row data structures with field-level validation and type conversion capabilities.
public class RowDataAssert extends AbstractAssert<RowDataAssert, RowData> {
public RowDataAssert(RowData rowData);
// Row properties
public RowDataAssert hasKind(RowKind kind);
public RowDataAssert hasArity(int arity);
// Field access and validation
public StringDataAssert getStringData(int index);
public StringAssert getString(int index);
public LongAssert getLong(int index);
public RowDataAssert isNullAt(int index);
public RowDataAssert isNotNullAt(int index);
// Type conversion
public RowDataAssert asGeneric(DataType dataType);
public RowDataAssert asGeneric(LogicalType logicalType);
/** Requires flink-table-runtime in classpath */
public RowAssert asRow(DataType dataType);
}import static org.apache.flink.table.test.TableAssertions.assertThat;
import org.apache.flink.table.data.RowData;
import org.apache.flink.types.RowKind;
// Basic row validation
RowData rowData = /* ... */;
assertThat(rowData)
.hasKind(RowKind.INSERT)
.hasArity(3)
.isNotNullAt(0)
.isNullAt(2);
// Field value assertions
assertThat(rowData)
.getString(0).isEqualTo("test")
.getLong(1).isEqualTo(42L);
// Type conversion for comparison
RowData expected = /* ... */;
DataType dataType = /* ... */;
assertThat(rowData)
.asGeneric(dataType)
.isEqualTo(expected);Assertions for external Row objects used in Table API.
public class RowAssert extends AbstractAssert<RowAssert, Row> {
public RowAssert(Row row);
public RowAssert hasKind(RowKind kind);
public RowAssert hasArity(int arity);
}import org.apache.flink.types.Row;
import org.apache.flink.types.RowKind;
Row row = Row.of("Alice", 25, true);
row.setKind(RowKind.INSERT);
assertThat(row)
.hasKind(RowKind.INSERT)
.hasArity(3);Assertions for Flink's internal array data structures.
public class ArrayDataAssert extends AbstractAssert<ArrayDataAssert, ArrayData> {
public ArrayDataAssert(ArrayData arrayData);
public ArrayDataAssert hasSize(int size);
public ArrayDataAssert asGeneric(DataType dataType);
public ArrayDataAssert asGeneric(LogicalType logicalType);
}import org.apache.flink.table.data.ArrayData;
import org.apache.flink.table.data.GenericArrayData;
ArrayData arrayData = new GenericArrayData(new Object[]{1, 2, 3});
assertThat(arrayData)
.hasSize(3);
// With type conversion
DataType arrayType = /* ... */;
assertThat(arrayData)
.asGeneric(arrayType)
.isEqualTo(expectedArray);Assertions for Flink's internal map data structures.
public class MapDataAssert extends AbstractAssert<MapDataAssert, MapData> {
public MapDataAssert(MapData mapData);
public MapDataAssert hasSize(int size);
public MapDataAssert asGeneric(DataType dataType);
public MapDataAssert asGeneric(LogicalType logicalType);
}import org.apache.flink.table.data.MapData;
import org.apache.flink.table.data.GenericMapData;
Map<Object, Object> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
MapData mapData = new GenericMapData(map);
// Basic size validation
assertThat(mapData)
.hasSize(2);
// Type conversion for comparison
DataType mapType = /* ... */;
assertThat(mapData)
.asGeneric(mapType)
.isEqualTo(expectedMap);Assertions for Flink's internal string data structures.
public class StringDataAssert extends AbstractAssert<StringDataAssert, StringData> {
public StringDataAssert(StringData stringData);
public StringAssert asString();
public ByteArrayAssert asBytes();
}import org.apache.flink.table.data.StringData;
import org.assertj.core.api.ByteArrayAssert;
import org.assertj.core.api.StringAssert;
StringData stringData = StringData.fromString("Hello World");
assertThat(stringData)
.isEqualTo(StringData.fromString("Hello World"));
// Convert to String for string-specific assertions
assertThat(stringData)
.asString()
.startsWith("Hello")
.endsWith("World")
.hasLength(11);
// Convert to byte array for byte-level assertions
assertThat(stringData)
.asBytes()
.hasSize(11)
.startsWith("Hello".getBytes());Factory methods for creating assertions when the exact data type is unknown at compile time.
import org.apache.flink.table.types.logical.LogicalType;
Object data = /* could be RowData, ArrayData, MapData, etc. */;
LogicalType logicalType = /* ... */;
// Creates appropriate assertion type based on actual data type
assertThatGenericDataOfType(data, logicalType)
.isEqualTo(expectedData);
// Works with DataType as well
DataType dataType = /* ... */;
assertThatGenericDataOfType(data, dataType)
.isNotNull();Install with Tessl CLI
npx tessl i tessl/maven-org-apache-flink--flink-table-test-utils