snuyanzin commented on code in PR #26385:
URL: https://github.com/apache/flink/pull/26385#discussion_r2059237729


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/api/TableEnvironmentTest.java:
##########
@@ -204,12 +303,52 @@ private static void 
assertTemporaryCreateTableFromDescriptor(
 
         final Optional<ContextResolvedTable> lookupResult =
                 tEnv.getCatalogManager().getTable(ObjectIdentifier.of(catalog, 
database, "T"));
-        assertThat(lookupResult.isPresent()).isTrue();
+        assertThat(lookupResult).isPresent();
 
         final CatalogBaseTable catalogTable = 
lookupResult.get().getResolvedTable();
         assertThat(catalogTable instanceof CatalogTable).isTrue();
         assertThat(catalogTable.getUnresolvedSchema()).isEqualTo(schema);
         
assertThat(catalogTable.getOptions().get("connector")).isEqualTo("fake");
         assertThat(catalogTable.getOptions().get("a")).isEqualTo("Test");
     }
+
+    private static void assertCreateModelFromDescriptor(
+            TableEnvironmentMock tEnv, String modelPath, ModelDescriptor 
modelDescriptor)
+            throws ModelNotExistException {
+        final String catalog = tEnv.getCurrentCatalog();
+        final String database = tEnv.getCurrentDatabase();
+
+        tEnv.createModel(modelPath, modelDescriptor, true);
+        final ObjectPath objectPath = new ObjectPath(database, modelPath);
+        CatalogModel catalogModel =
+                
tEnv.getCatalog(catalog).orElseThrow(AssertionError::new).getModel(objectPath);
+        assertCatalogModelWithModelDescriptor(catalogModel, modelDescriptor);
+    }
+
+    private static void assertTemporaryCreateModelFromDescriptor(
+            TableEnvironmentMock tEnv, String modelPath, ModelDescriptor 
modelDescriptor) {
+        final String catalog = tEnv.getCurrentCatalog();
+        final String database = tEnv.getCurrentDatabase();
+
+        tEnv.createTemporaryModel(modelPath, modelDescriptor, true);
+        final Optional<ContextResolvedModel> lookupResult =
+                tEnv.getCatalogManager()
+                        .getModel(ObjectIdentifier.of(catalog, database, 
modelPath));
+        assertThat(lookupResult).isPresent();
+        CatalogModel catalogModel = lookupResult.get().getResolvedModel();
+        assertCatalogModelWithModelDescriptor(catalogModel, modelDescriptor);
+    }
+
+    private static void assertCatalogModelWithModelDescriptor(
+            CatalogModel catalogModel, ModelDescriptor modelDescriptor) {
+        assertThat(catalogModel).isNotNull();
+        assertThat(catalogModel).isInstanceOf(CatalogModel.class);
+        
assertThat(catalogModel.getInputSchema()).isEqualTo(modelDescriptor.getInputSchema().get());
+        assertThat(catalogModel.getOutputSchema())
+                .isEqualTo(modelDescriptor.getOutputSchema().get());
+        for (Map.Entry<String, String> entry : 
modelDescriptor.getOptions().entrySet()) {
+            assertThat(catalogModel.getOptions()).contains(entry);
+            
assertThat(catalogModel.getOptions().get(entry.getKey())).isEqualTo(entry.getValue());

Review Comment:
   ```suggestion
               
assertThat(catalogModel.getOptions()).containsEntry(entry.getKey(), 
entry.getValue());
   ```



-- 
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

Reply via email to