or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

collection-assertions.mddata-assertions.mdindex.mdlookup-cache-assertions.mdtype-assertions.md
tile.json

tessl/maven-org-apache-flink--flink-table-test-utils

Test utilities for Apache Flink's Table API and SQL ecosystem enabling robust testing of table operations and data transformations.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apache.flink/flink-table-test-utils@2.1.x

To install, run

npx @tessl/cli install tessl/maven-org-apache-flink--flink-table-test-utils@2.1.0

index.mddocs/

Apache Flink Table Test Utils

A comprehensive test utilities library for Apache Flink's Table API and SQL ecosystem. This library provides fluent assertion APIs that simplify validation of table processing results, supporting both internal RowData structures and external Row representations with automatic type conversion capabilities.

Package Information

  • Package Name: flink-table-test-utils
  • Package Type: Maven
  • Group ID: org.apache.flink
  • Artifact ID: flink-table-test-utils
  • Language: Java
  • Installation:
    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-table-test-utils</artifactId>
      <version>2.1.0</version>
      <scope>test</scope>
    </dependency>

Core Imports

import static org.apache.flink.table.test.TableAssertions.*;

For specific assertion types:

import org.apache.flink.table.test.RowDataAssert;
import org.apache.flink.table.test.RowAssert;
import org.apache.flink.table.test.ArrayDataAssert;
import org.apache.flink.table.test.MapDataAssert;
import org.apache.flink.table.test.StringDataAssert;
import org.apache.flink.table.test.RowDataListAssert;
import org.apache.flink.table.test.DataTypeAssert;
import org.apache.flink.table.test.LogicalTypeAssert;
import org.apache.flink.table.test.lookup.cache.LookupCacheAssert;

Basic Usage

import static org.apache.flink.table.test.TableAssertions.*;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.types.DataType;
import org.apache.flink.types.RowKind;

// Assert on RowData
RowData rowData = /* ... */;
assertThat(rowData)
    .hasKind(RowKind.INSERT)
    .hasArity(3)
    .isNotNullAt(0);

// Assert on collections with type conversion
List<RowData> rows = /* ... */;
DataType dataType = /* ... */;
assertThatRows(rows)
    .asGeneric(dataType)
    .containsOnly(expectedRow);

// Assert on data types
assertThat(dataType)
    .isNullable()
    .hasLogicalType(expectedLogicalType);

Architecture

The library is built around the TableAssertions entry point class that provides static factory methods for creating type-specific assertion objects. Each assertion class extends AssertJ's AbstractAssert to provide fluent assertion APIs:

  • Entry Point: TableAssertions - Central factory for all assertion types
  • Data Assertions: Specialized assertion classes for Flink's internal data structures
  • Type Assertions: Utilities for validating Flink's type system
  • Conversion Utilities: Automatic type conversion between internal and external representations

Capabilities

Main Entry Point

Entry point factory methods for creating assertions.

public class TableAssertions {
    // External data structures
    public static RowAssert assertThat(Row row);
    
    // Internal data structures  
    public static RowDataAssert assertThat(RowData actual);
    public static ArrayDataAssert assertThat(ArrayData actual);
    public static MapDataAssert assertThat(MapData actual);
    public static StringDataAssert assertThat(StringData actual);
    
    // Collection assertions
    public static RowDataListAssert assertThatRows(Iterator<RowData> actual);
    public static RowDataListAssert assertThatRows(Iterable<RowData> actual);
    public static RowDataListAssert assertThatRows(Stream<RowData> actual);
    public static RowDataListAssert assertThatRows(RowData... rows);
    
    // Generic type assertions
    public static AbstractAssert<?, ?> assertThatGenericDataOfType(Object actual, LogicalType logicalType);
    public static AbstractAssert<?, ?> assertThatGenericDataOfType(Object actual, DataType dataType);
    
    // Type system assertions
    public static DataTypeAssert assertThat(DataType actual);
    public static LogicalTypeAssert assertThat(LogicalType actual);
}

Data Structure Assertions

Fluent assertions for Flink's internal data structures including RowData, ArrayData, MapData, and StringData with type conversion capabilities.

Type System Assertions

Comprehensive assertions for Flink's DataType and LogicalType system with validation of type properties, conversions, and hierarchies.

Collection Assertions

Specialized assertions for collections of RowData with bulk operations and type-safe comparisons.

Lookup Cache Assertions

Validation utilities for Flink's lookup cache functionality with key-value relationship testing.

Types

Core Types

// From org.apache.flink.table.data
interface RowData extends Serializable {
    int getArity();
    RowKind getRowKind();
    boolean isNullAt(int pos);
}

interface ArrayData extends Serializable {
    int size();
    boolean isNullAt(int pos);
}

interface MapData extends Serializable {
    int size();
    ArrayData keyArray();
    ArrayData valueArray();
}

interface StringData extends Serializable {
    int numBytes();
    byte[] toBytes();
    String toString();
}

External Types

// From org.apache.flink.types
class Row implements Serializable {
    public Row(int arity);
    public int getArity();
    public RowKind getKind();
    public Object getField(int pos);
    public void setField(int pos, Object value);
}

enum RowKind {
    INSERT, UPDATE_BEFORE, UPDATE_AFTER, DELETE
}

Type System Types

// From org.apache.flink.table.types
class DataType implements Serializable {
    public LogicalType getLogicalType();
    public Class<?> getConversionClass();
    public List<DataType> getChildren();
    public DataType nullable();
    public DataType notNull();
}

// From org.apache.flink.table.types.logical
abstract class LogicalType implements Serializable {
    public boolean isNullable();
    public List<LogicalType> getChildren();
    public String asSummaryString();
    public boolean supportsInputConversion(Class<?> clazz);
    public boolean supportsOutputConversion(Class<?> clazz);
}

Assertion Result Types

// From org.assertj.core.api
abstract class AbstractAssert<SELF extends AbstractAssert<SELF, ACTUAL>, ACTUAL> {
    public SELF isEqualTo(Object expected);
    public SELF isNotEqualTo(Object expected);
    public SELF isNotNull();
    public SELF isNull();
}

class StringAssert extends AbstractAssert<StringAssert, String> {
    public StringAssert isEqualTo(String expected);
    public StringAssert contains(CharSequence... values);
    public StringAssert startsWith(String prefix);
}

class LongAssert extends AbstractAssert<LongAssert, Long> {
    public LongAssert isEqualTo(long expected);
    public LongAssert isGreaterThan(long other);
    public LongAssert isLessThan(long other);
}

class ListAssert<ELEMENT> extends AbstractAssert<ListAssert<ELEMENT>, List<? extends ELEMENT>> {
    public ListAssert<ELEMENT> containsOnly(ELEMENT... values);
    public ListAssert<ELEMENT> containsExactly(ELEMENT... values);
    public ListAssert<ELEMENT> hasSize(int expected);
}

class ByteArrayAssert extends AbstractAssert<ByteArrayAssert, byte[]> {
    public ByteArrayAssert hasSize(int expected);
    public ByteArrayAssert startsWith(byte... sequence);
    public ByteArrayAssert endsWith(byte... sequence);
}