Ethanlm commented on a change in pull request #3215: Storm3585 - New compact 
Constraint config including maxCoLocationCnt
URL: https://github.com/apache/storm/pull/3215#discussion_r387448197
 
 

 ##########
 File path: storm-client/test/jvm/org/apache/storm/TestConfigValidate.java
 ##########
 @@ -541,6 +547,127 @@ public void testMapEntryCustomAnnotation() throws 
InvocationTargetException, NoS
         }
     }
 
+    @Test
+    public void testExactlyOneOfCustomAnnotation() throws 
InvocationTargetException, NoSuchMethodException, NoSuchFieldException,
+            InstantiationException, IllegalAccessException {
+        TestConfig config = new TestConfig();
+        Collection<Object> passCases = new LinkedList<Object>();
+        Collection<Object> failCases = new LinkedList<Object>();
+
+        List<Object> passCaseListOfList = new ArrayList<>();
+        passCaseListOfList.add(Arrays.asList("comp1", "comp2"));
+        passCaseListOfList.add(Arrays.asList("comp1", "comp3"));
+        passCaseListOfList.add(Arrays.asList("comp2", "comp4"));
+        passCaseListOfList.add(Arrays.asList("comp2", "comp5"));
+
+        Map<Object, Object> passCaseMapOfMap = new HashMap<>();
+        passCaseMapOfMap.put("comp1",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, 
(Integer)10 },
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, 
Arrays.asList("comp2", "comp3")},
+                }).collect(Collectors.toMap(data -> data[0], data -> data[1]))
+        );
+        passCaseMapOfMap.put("comp2",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, 
(Integer)2 },
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, 
Arrays.asList("comp4", "comp5")},
+                }).collect(Collectors.toMap(data -> data[0], data -> data[1]))
+        );
+        passCases.add(passCaseMapOfMap);
+
+        passCaseMapOfMap = new HashMap<>();
+        passCaseMapOfMap.put("comp1",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, 
Arrays.asList("comp2", "comp3")},
+                }).collect(Collectors.toMap(data -> data[0], data -> data[1]))
+        );
+        passCaseMapOfMap.put("comp2",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, 
(Integer)2 },
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, 
Arrays.asList("comp4", "comp5")},
+                }).collect(Collectors.toMap(data -> data[0], data -> data[1]))
+        );
+        passCases.add(passCaseMapOfMap);
+
+        passCaseMapOfMap = new HashMap<>();
+        passCaseMapOfMap.put("comp1",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, "comp2"},
+                }).collect(Collectors.toMap(data -> data[0], data -> data[1]))
+        );
+        passCaseMapOfMap.put("comp2",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, 
(Integer)2 },
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, "comp4"},
+                }).collect(Collectors.toMap(data -> data[0], data -> data[1]))
+        );
+        passCases.add(passCaseMapOfMap);
+
+        for (Object value : passCases) {
+            config.put(TestConfig.TEST_MAP_CONFIG_9, value);
+            ConfigValidation.validateFields(config, 
Arrays.asList(TestConfig.class));
+        }
+
+        List<Object> failCaseList = new ArrayList<>();
+        failCaseList.add(Arrays.asList("comp1", Arrays.asList("comp2", 
"comp3")));
+        failCaseList.add(Arrays.asList("comp3", Arrays.asList("comp4", 
"comp5")));
+        failCases.add(failCaseList);
+
+        Map<String, Object> failCaseMapOfMap = new HashMap<>();
+        failCaseMapOfMap.put("comp1",
+                Stream.of(new Object[][] {
+                        { 
RasConstraintsTypeValidator.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, 
(Integer)10 },
 
 Review comment:
   (Integer) can be removed

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to