slinkydeveloper commented on a change in pull request #18464:
URL: https://github.com/apache/flink/pull/18464#discussion_r791698085



##########
File path: 
flink-table/flink-table-common/src/test/java/org/apache/flink/table/module/CoreModuleTest.java
##########
@@ -18,14 +18,56 @@
 
 package org.apache.flink.table.module;
 
+import org.apache.flink.table.functions.BuiltInFunctionDefinition;
+
 import org.junit.Test;
 
-import static org.junit.Assert.assertFalse;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Test for {@link CoreModule}. */
 public class CoreModuleTest {
+
+    @Test
+    public void testListFunctions() {
+        assertThat(CoreModule.INSTANCE.listFunctions(false))
+                .contains("IFNULL")
+                .doesNotContain("$REPLICATE_ROWS$1");
+
+        assertThat(CoreModule.INSTANCE.listFunctions(true))
+                .contains("IFNULL")
+                .contains("$REPLICATE_ROWS$1");
+    }
+
     @Test
     public void testGetNonExistFunction() {
-        
assertFalse(CoreModule.INSTANCE.getFunctionDefinition("nonexist").isPresent());
+        
assertThat(CoreModule.INSTANCE.getFunctionDefinition("nonexist")).isEmpty();
+    }
+
+    @Test
+    public void testGetFunction() {
+        assertThat(CoreModule.INSTANCE.getFunctionDefinition("CAST"))
+                .hasValueSatisfying(
+                        def ->
+                                assertThat(def)
+                                        .isInstanceOfSatisfying(
+                                                
BuiltInFunctionDefinition.class,
+                                                builtInDef ->
+                                                        
assertThat(builtInDef.getQualifiedName())
+                                                                
.isEqualTo("$CAST$1")));

Review comment:
       You can simplify this with:
   
   
   ```
           assertThat(CoreModule.INSTANCE.getFunctionDefinition("CAST"))
                   .hasValueSatisfying(
                           def ->
                                   assertThat(def)
                                           
.asInstanceOf(InstanceOfAssertFactories.type(BuiltInFunctionDefinition.class))
                                           
.extracting(BuiltInFunctionDefinition::getQualifiedName)
                                           .isEqualTo("$CAST$1"))
   ```

##########
File path: 
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/module/ModuleManagerTest.java
##########
@@ -54,14 +48,15 @@ public void before() {
     @Test
     public void testLoadModuleTwice() {
         // CoreModule is loaded by default
-        assertEquals(
-                Collections.singletonList(CoreModuleFactory.IDENTIFIER), 
manager.getUsedModules());
-        assertEquals(
-                CoreModule.INSTANCE, 
manager.getLoadedModules().get(CoreModuleFactory.IDENTIFIER));
-
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("A module with name 'core' already exists");
-        manager.loadModule(CoreModuleFactory.IDENTIFIER, CoreModule.INSTANCE);
+        assertThat(manager.getUsedModules())
+                
.isEqualTo(Collections.singletonList(CoreModuleFactory.IDENTIFIER));
+        
assertThat(manager.getLoadedModules().get(CoreModuleFactory.IDENTIFIER))
+                .isEqualTo(CoreModule.INSTANCE);

Review comment:
       `isSameAs` to check the instance?




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


Reply via email to