Source:
<code>public void testNewConstraintFormat() { String s = String.format( "{ \"comp-1\": " + " { \"%s\": 2, " + " \"%s\": [\"comp-2\", \"comp-3\" ] }, " + " \"comp-2\": " + " { \"%s\": [ \"comp-4\" ] }, " + " \"comp-3\": " + " { \"%s\": \"comp-5\" } " + "}", ConstraintSolverStrategy.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS ); Object jsonValue = JSONValue.parse(s); Map<String, Object> config = Utils.readDefaultConfig(); config.put(Config.TOPOLOGY_RAS_CONSTRAINTS, jsonValue); Set<String> allComps = new HashSet<>(); allComps.addAll(Arrays.asList("comp-1", "comp-2", "comp-3", "comp-4", "comp-5")); ConstraintSolverStrategy.ConstraintConfig constraintConfig = new ConstraintSolverStrategy.ConstraintConfig(config, allComps); Set<String> expectedSetComp1 = new HashSet<>(); expectedSetComp1.addAll(Arrays.asList("comp-2", "comp-3")); Set<String> expectedSetComp2 = new HashSet<>(); expectedSetComp2.addAll(Arrays.asList("comp-1", "comp-4")); Set<String> expectedSetComp3 = new HashSet<>(); expectedSetComp3.addAll(Arrays.asList("comp-1", "comp-5")); Assert.assertEquals("comp-1 incompatible components", expectedSetComp1, constraintConfig.getIncompatibleComponents().get("comp-1")); Assert.assertEquals("comp-2 incompatible components", expectedSetComp2, constraintConfig.getIncompatibleComponents().get("comp-2")); Assert.assertEquals("comp-3 incompatible components", expectedSetComp3, constraintConfig.getIncompatibleComponents().get("comp-3")); <START> Assert.assertEquals("comp-1 maxNodeCoLocationCnt", (int)2, (int)constraintConfig.getMaxCoLocationCnts().getOrDefault("comp-1", -1)); <END> Assert.assertNull("comp-2 maxNodeCoLocationCnt", constraintConfig.getMaxCoLocationCnts().get("comp-2")); }</code><technical_language>nit: space (int)</technical_language>

Target:
public void testNewConstraintFormat() { String s = String.format( "{ \"comp-1\": " + " { \"%s\": 2, " + " \"%s\": [\"comp-2\", \"comp-3\" ] }, " + " \"comp-2\": " + " { \"%s\": [ \"comp-4\" ] }, " + " \"comp-3\": " + " { \"%s\": \"comp-5\" } " + "}", ConstraintSolverStrategy.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS, ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS ); Object jsonValue = JSONValue.parse(s); Map<String, Object> config = Utils.readDefaultConfig(); config.put(Config.TOPOLOGY_RAS_CONSTRAINTS, jsonValue); Set<String> allComps = new HashSet<>(); allComps.addAll(Arrays.asList("comp-1", "comp-2", "comp-3", "comp-4", "comp-5")); ConstraintSolverStrategy.ConstraintConfig constraintConfig = new ConstraintSolverStrategy.ConstraintConfig(config, allComps); Set<String> expectedSetComp1 = new HashSet<>(); expectedSetComp1.addAll(Arrays.asList("comp-2", "comp-3")); Set<String> expectedSetComp2 = new HashSet<>(); expectedSetComp2.addAll(Arrays.asList("comp-1", "comp-4")); Set<String> expectedSetComp3 = new HashSet<>(); expectedSetComp3.addAll(Arrays.asList("comp-1", "comp-5")); Assert.assertEquals("comp-1 incompatible components", expectedSetComp1, constraintConfig.getIncompatibleComponents().get("comp-1")); Assert.assertEquals("comp-2 incompatible components", expectedSetComp2, constraintConfig.getIncompatibleComponents().get("comp-2")); Assert.assertEquals("comp-3 incompatible components", expectedSetComp3, constraintConfig.getIncompatibleComponents().get("comp-3")); Assert.assertEquals("comp-1 maxNodeCoLocationCnt", 2, (int) constraintConfig.getMaxCoLocationCnts().getOrDefault("comp-1", -1)); Assert.assertNull("comp-2 maxNodeCoLocationCnt", constraintConfig.getMaxCoLocationCnts().get("comp-2")); }