snuyanzin commented on code in PR #26385:
URL: https://github.com/apache/flink/pull/26385#discussion_r2059226220
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/api/TableEnvironmentTest.java:
##########
@@ -158,6 +177,86 @@ void testTableFromDescriptor() {
assertThat(tEnv.getCatalogManager().listTables()).isEmpty();
}
+ @ParameterizedTest()
+ @MethodSource("getModelNamesAndDescriptors")
+ void testCreateModelFromDescriptor(String modelPath, ModelDescriptor
modelDescriptor)
+ throws Exception {
+ assertCreateModelFromDescriptor(tEnv, modelPath, modelDescriptor);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testCreateModelWithSameNameWithIgnoreIfExists(boolean ignoreIfExists)
throws Exception {
+ assertCreateModelFromDescriptor(tEnv, "M", TEST_MODEL_DESCRIPTOR);
+
+ if (ignoreIfExists) {
+ assertThatNoException()
+ .isThrownBy(() -> tEnv.createModel("M",
TEST_MODEL_DESCRIPTOR, true));
+ } else {
+ 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`");
+ }
+
+ @Test
+ void testDropModel() throws Exception {
+ tEnv.createModel("M", TEST_MODEL_DESCRIPTOR);
+
+ final String catalog = tEnv.getCurrentCatalog();
+ final String database = tEnv.getCurrentDatabase();
+ final ObjectPath objectPath = new ObjectPath(database, "M");
+ CatalogModel catalogModel =
+
tEnv.getCatalog(catalog).orElseThrow(AssertionError::new).getModel(objectPath);
+ assertThat(catalogModel).isInstanceOf(CatalogModel.class);
+ assertThat(tEnv.dropModel("M", true)).isTrue();
+ assertThatThrownBy(
+ () ->
+ tEnv.getCatalog(catalog)
+ .orElseThrow(AssertionError::new)
+ .getModel(objectPath))
+ .isInstanceOf(ModelNotExistException.class)
+ .hasMessage("Model '`default_catalog`.`default_database`.`M`'
does not exist.");
+ }
+
+ @Test
+ void testNonExistingDropModel() throws Exception {
+ assertThat(tEnv.dropModel("M", true)).isFalse();
+
+ assertThatThrownBy(() -> tEnv.dropModel("M", false))
+ .isInstanceOf(ValidationException.class)
+ .hasMessage(
+ "Model with identifier
'default_catalog.default_database.M' does not exist.");
+ }
+
+ @ParameterizedTest()
Review Comment:
```suggestion
@ParameterizedTest
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]