Search in sources :

Example 1 with DynamicTableSourceMock

use of org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock in project flink by apache.

the class FactoryUtilTest method testAllOptions.

@Test
public void testAllOptions() {
    final Map<String, String> options = createAllOptions();
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, new DecodingFormatMock(",", false), new DecodingFormatMock("|", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, new EncodingFormatMock(","), new EncodingFormatMock("|"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Example 2 with DynamicTableSourceMock

use of org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock in project flink by apache.

the class FactoryUtilTest method testDiscoveryForSeparateSourceSinkFactory.

@Test
public void testDiscoveryForSeparateSourceSinkFactory() {
    final Map<String, String> options = createAllOptions();
    // the "test" source and sink factory is not in one factory class
    // see TestDynamicTableSinkFactory and TestDynamicTableSourceFactory
    options.put("connector", "test");
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, new DecodingFormatMock(",", false), new DecodingFormatMock("|", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, new EncodingFormatMock(","), new EncodingFormatMock("|"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Example 3 with DynamicTableSourceMock

use of org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock in project flink by apache.

the class FactoryUtilTest method testAlternativeValueFormat.

@Test
public void testAlternativeValueFormat() {
    final Map<String, String> options = createAllOptions();
    options.remove("value.format");
    options.remove("value.test-format.delimiter");
    options.remove("value.test-format.fail-on-missing");
    options.put("format", "test-format");
    options.put("test-format.delimiter", ";");
    options.put("test-format.fail-on-missing", "true");
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, new DecodingFormatMock(",", false), new DecodingFormatMock(";", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, new EncodingFormatMock(","), new EncodingFormatMock(";"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Example 4 with DynamicTableSourceMock

use of org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock in project flink by apache.

the class FactoryUtilTest method testOptionalFormat.

@Test
public void testOptionalFormat() {
    final Map<String, String> options = createAllOptions();
    options.remove("key.format");
    options.remove("key.test-format.delimiter");
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, null, new DecodingFormatMock("|", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, null, new EncodingFormatMock("|"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Aggregations

DynamicTableSink (org.apache.flink.table.connector.sink.DynamicTableSink)4 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)4 DynamicTableSinkMock (org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock)4 DynamicTableSourceMock (org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock)4 DecodingFormatMock (org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock)4 EncodingFormatMock (org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock)4 Test (org.junit.jupiter.api.Test)4