snuyanzin commented on code in PR #26385: URL: https://github.com/apache/flink/pull/26385#discussion_r2031786003
########## flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/api/TableEnvironmentTest.java: ########## @@ -158,6 +167,121 @@ void testTableFromDescriptor() { assertThat(tEnv.getCatalogManager().listTables()).isEmpty(); } + @Test + void testCreateModelFromDescriptor() throws Exception { + final TableEnvironmentMock tEnv = TableEnvironmentMock.getStreamingInstance(); + + assertCreateModelFromDescriptor(tEnv, false); + } + + @Test + void testCreateModelIgnoreIfExistsFromDescriptor() throws Exception { + final TableEnvironmentMock tEnv = TableEnvironmentMock.getStreamingInstance(); + + assertCreateModelFromDescriptor(tEnv, true); + assertThatNoException() + .isThrownBy(() -> tEnv.createModel("M", TEST_MODEL_DESCRIPTOR, true)); + + assertThatThrownBy(() -> tEnv.createModel("M", TEST_MODEL_DESCRIPTOR, false)) + .isInstanceOf(ValidationException.class) + .hasMessage( + "Could not execute CreateModel in path `default_catalog`.`default_database`.`M`"); + } + + @Test + void testCreateModelWithSameName() { + final TableEnvironmentMock tEnv = TableEnvironmentMock.getStreamingInstance(); + + tEnv.createModel("M", TEST_MODEL_DESCRIPTOR); + + tEnv.createModel("M", TEST_MODEL_DESCRIPTOR, true); + + assertThatThrownBy(() -> tEnv.createModel("M", TEST_MODEL_DESCRIPTOR, false)) + .isInstanceOf(ValidationException.class) + .hasMessage( + "Could not execute CreateModel in path `default_catalog`.`default_database`.`M`"); + + assertThatThrownBy(() -> tEnv.createModel("M", TEST_MODEL_DESCRIPTOR)) + .isInstanceOf(ValidationException.class) + .hasMessage( + "Could not execute CreateModel in path `default_catalog`.`default_database`.`M`"); + } Review Comment: couldn't it be simplified with parameterized test? -- 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