tombentley commented on a change in pull request #8755:
URL: https://github.com/apache/kafka/pull/8755#discussion_r432604315



##########
File path: 
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ConnectorConfigTest.java
##########
@@ -434,5 +436,63 @@ public void configure(Map<String, ?> configs) {
         }
     }
 
+    @Test
+    public void testConfigDefOverrideByInitialConfigDef() {
+        String alias = "hdt";
+        String prefix = ConnectorConfig.TRANSFORMS_CONFIG + "." + alias + ".";
+        Map<String, String> props = new HashMap<>();
+        props.put(ConnectorConfig.TRANSFORMS_CONFIG, alias);
+        props.put(prefix + "type", 
HasDuplicateConfigTransformation.class.getName());
+        ConfigDef def = ConnectorConfig.enrich(MOCK_PLUGINS,
+                new ConfigDef(),
+                props,
+                false);
+
+        Arrays.asList(PredicatedTransformation.PREDICATE_CONFIG,
+                PredicatedTransformation.NEGATE_CONFIG,
+                HasDuplicateConfigTransformation.MUST_EXIST_KEY)
+                .forEach(key -> {
+                    Assert.assertNotNull(def.configKeys().get(prefix + key));
+                    Assert.assertNull(def.configKeys().get(key));
+                });
+
+        Arrays.asList(PredicatedTransformation.PREDICATE_CONFIG,
+                PredicatedTransformation.NEGATE_CONFIG)
+                .forEach(key -> Assert.assertNotEquals(
+                        
HasDuplicateConfigTransformation.CONFIG_DEF.configKeys().get(key).type,
+                        def.configKeys().get(prefix + key).type));
+    }

Review comment:
       There are already static imports for some Assert methods, so no reason 
not to make assertNull and assertNotNull static imports too.
   
   And I don't think the `asList()/forEach()` are really providing much benefit 
here. It would be clearer if you factored out a method:
   
   ```java
           assertNotNull(def.configKeys().get(prefix + 
HasDuplicateConfigTransformation.MUST_EXIST_KEY));
           
assertNull(def.configKeys().get(HasDuplicateConfigTransformation.MUST_EXIST_KEY));
           assertImplicitConfigDef(def, prefix, 
PredicatedTransformation.PREDICATE_CONFIG, ConfigDef.Type.STRING);
           assertImplicitConfigDef(def, prefix, 
PredicatedTransformation.NEGATE_CONFIG, ConfigDef.Type.BOOLEAN);
       }
   
       private void assertImplicitConfigDef(ConfigDef def, String prefix, 
String keyName, ConfigDef.Type expectedType) {
           assertNull(def.configKeys().get(keyName));
           ConfigDef.ConfigKey configKey = def.configKeys().get(prefix + 
keyName);
           assertNotNull("Implicit '" + prefix + keyName + "' config must be 
present", configKey);
           assertEquals("Implicit '" + prefix + keyName + "' config should be a 
" + expectedType,
                   expectedType, configKey.type);
       }
   ```




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to