XComp commented on code in PR #21971: URL: https://github.com/apache/flink/pull/21971#discussion_r1112201535
########## flink-table/flink-table-api-java-bridge/src/test/java/org/apache/flink/table/factories/DataGenTableSourceFactoryTest.java: ########## @@ -264,57 +267,63 @@ void testSequenceCheckpointRestore() throws Exception { } @Test - void testLackStartForSequence() { - assertThatThrownBy( - () -> { - DescriptorProperties descriptor = new DescriptorProperties(); - descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen"); - descriptor.putString( - DataGenConnectorOptionsUtil.FIELDS - + ".f0." - + DataGenConnectorOptionsUtil.KIND, - DataGenConnectorOptionsUtil.SEQUENCE); - descriptor.putLong( - DataGenConnectorOptionsUtil.FIELDS - + ".f0." - + DataGenConnectorOptionsUtil.END, - 100); + void testDefaultValueForSequence() { + DescriptorProperties descriptor = new DescriptorProperties(); + descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen"); + descriptor.putString( + DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, + DataGenConnectorOptionsUtil.SEQUENCE); - createTableSource( - ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), - descriptor.asMap()); - }) - .satisfies( - anyCauseMatches( - ValidationException.class, - "Could not find required property 'fields.f0.start' for sequence generator.")); + DataGenTableSource source = + (DataGenTableSource) + createTableSource( + ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), + descriptor.asMap()); + DataGenerator<?>[] fieldGenerators = source.getFieldGenerators(); + SequenceGenerator<?> fieldGenerator = (SequenceGenerator<?>) fieldGenerators[0]; + long start = fieldGenerator.getStart(); + long end = fieldGenerator.getEnd(); + + Assertions.assertThat(0) + .describedAs("The default start value should be 0") + .isEqualTo(start); + Assertions.assertThat(Integer.MAX_VALUE) + .describedAs("The default start value should be Integer.MAX_VALUE") + .isEqualTo(end); } @Test - void testLackEndForSequence() { - assertThatThrownBy( - () -> { - DescriptorProperties descriptor = new DescriptorProperties(); - descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen"); - descriptor.putString( - DataGenConnectorOptionsUtil.FIELDS - + ".f0." - + DataGenConnectorOptionsUtil.KIND, - DataGenConnectorOptionsUtil.SEQUENCE); - descriptor.putLong( - DataGenConnectorOptionsUtil.FIELDS - + ".f0." - + DataGenConnectorOptionsUtil.START, - 0); - - createTableSource( - ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), - descriptor.asMap()); - }) - .satisfies( - anyCauseMatches( - ValidationException.class, - "Could not find required property 'fields.f0.end' for sequence generator.")); + void testStartEndForSequence() { + DescriptorProperties descriptor = new DescriptorProperties(); + descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen"); + descriptor.putString( + DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, + DataGenConnectorOptionsUtil.SEQUENCE); + int setupStart = 0; Review Comment: It's not helpful to use the default value here because you cannot check that the "set" value is used instead of the default value. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org