SingleValueAssignExtension implements CustomTagExtension<Assign> { public List<Map<String, String>> pipelinePossibleStates(Assign action, List<Map<String, String>> possibleStateList) { for (Map<String, String> possibleState : possibleStateList) { possibleState.put(action.getName(), action.getExpr()); } return possibleStateList; }  Class<Assign> getTagActionClass(); String getTagName(); String getTagNameSpace(); List<Map<String, String>> pipelinePossibleStates(Assign action, List<Map<String, String>> possibleStateList);  }
@Test public void pipelineEmptyListTest() { List<Map<String, String>> emptyList = new LinkedList<>(); SingleValueAssignExtension assign = new SingleValueAssignExtension(); Assign concreteAssignTag = new Assign(); concreteAssignTag.setName("var_out_test"); concreteAssignTag.setExpr("A"); List<Map<String, String>> processedList = assign.pipelinePossibleStates(concreteAssignTag, emptyList); Assert.assertNotNull(processedList); Assert.assertEquals(0, processedList.size()); }
@Test public void pipelineEmptyMapTest() { List<Map<String, String>> listWithEmptyMap = new LinkedList<>(); listWithEmptyMap.add(new HashMap<String, String>()); SingleValueAssignExtension assign = new SingleValueAssignExtension(); Assign concreteAssignTag = new Assign(); concreteAssignTag.setName("var_out_test"); concreteAssignTag.setExpr("A"); List<Map<String, String>> processedList = assign.pipelinePossibleStates(concreteAssignTag, listWithEmptyMap); Assert.assertEquals(1, processedList.size()); Map<String, String> resultMap = processedList.get(0); Assert.assertEquals(1, resultMap.keySet().size()); Assert.assertEquals("A", resultMap.get("var_out_test")); }
@Test public void pipelineNonEmptyMapTest() { List<Map<String, String>> listWithNonEmptyMap = new LinkedList<>(); HashMap<String, String> nonEmptyMap = new HashMap<>(); nonEmptyMap.put("var_out_test_1", "Lorem"); nonEmptyMap.put("var_out_test_2", "ipsum"); nonEmptyMap.put("var_out_test_3", "doler"); nonEmptyMap.put("var_out_test_4", "sit"); nonEmptyMap.put("var_out_test_5", "amet"); listWithNonEmptyMap.add(nonEmptyMap); SingleValueAssignExtension assign = new SingleValueAssignExtension(); Assign concreteAssignTag = new Assign(); concreteAssignTag.setName("var_out_test_6"); concreteAssignTag.setExpr("consectetur"); List<Map<String, String>> processedList = assign.pipelinePossibleStates(concreteAssignTag, listWithNonEmptyMap); Assert.assertEquals(1, processedList.size()); Map<String, String> resultMap = processedList.get(0); Assert.assertEquals(6, resultMap.keySet().size()); Assert.assertEquals("Lorem", resultMap.get("var_out_test_1")); Assert.assertEquals("ipsum", resultMap.get("var_out_test_2")); Assert.assertEquals("doler", resultMap.get("var_out_test_3")); Assert.assertEquals("sit", resultMap.get("var_out_test_4")); Assert.assertEquals("amet", resultMap.get("var_out_test_5")); Assert.assertEquals("consectetur", resultMap.get("var_out_test_6")); }
@Test public void pipelineOverwriteTest() { List<Map<String, String>> listWithNonEmptyMap = new LinkedList<>(); HashMap<String, String> nonEmptyMap = new HashMap<>(); nonEmptyMap.put("var_out_test", "Lorem"); listWithNonEmptyMap.add(nonEmptyMap); SingleValueAssignExtension assign = new SingleValueAssignExtension(); Assign concreteAssignTag = new Assign(); concreteAssignTag.setName("var_out_test"); concreteAssignTag.setExpr("consectetur"); List<Map<String, String>> processedList = assign.pipelinePossibleStates(concreteAssignTag, listWithNonEmptyMap); Assert.assertEquals(1, processedList.size()); Map<String, String> resultMap = processedList.get(0); Assert.assertEquals(1, resultMap.keySet().size()); Assert.assertEquals("consectetur", resultMap.get("var_out_test")); }
@Test public void pipelineMultipleMapsTest() { List<Map<String, String>> listWithManyMaps = new LinkedList<>(); HashMap<String, String> nonEmptyMapOne = new HashMap<>(); nonEmptyMapOne.put("var_out_test_1", "Lorem"); nonEmptyMapOne.put("var_out_test_2", "ipsum"); listWithManyMaps.add(nonEmptyMapOne); HashMap<String, String> nonEmptyMapTwo = new HashMap<>(nonEmptyMapOne); listWithManyMaps.add(nonEmptyMapTwo); HashMap<String, String> nonEmptyMapThree = new HashMap<>(nonEmptyMapOne); listWithManyMaps.add(nonEmptyMapThree); SingleValueAssignExtension assign = new SingleValueAssignExtension(); Assign concreteAssignTag = new Assign(); concreteAssignTag.setName("var_out_test_3"); concreteAssignTag.setExpr("consectetur"); List<Map<String, String>> processedList = assign.pipelinePossibleStates(concreteAssignTag, listWithManyMaps); Assert.assertEquals(3, processedList.size()); Map<String, String> resultMap = processedList.get(0); Assert.assertEquals(3, resultMap.keySet().size()); Assert.assertEquals("Lorem", resultMap.get("var_out_test_1")); Assert.assertEquals("ipsum", resultMap.get("var_out_test_2")); Assert.assertEquals("consectetur", resultMap.get("var_out_test_3")); resultMap = processedList.get(1); Assert.assertEquals(3, resultMap.keySet().size()); Assert.assertEquals("Lorem", resultMap.get("var_out_test_1")); Assert.assertEquals("ipsum", resultMap.get("var_out_test_2")); Assert.assertEquals("consectetur", resultMap.get("var_out_test_3")); resultMap = processedList.get(2); Assert.assertEquals(3, resultMap.keySet().size()); Assert.assertEquals("Lorem", resultMap.get("var_out_test_1")); Assert.assertEquals("ipsum", resultMap.get("var_out_test_2")); Assert.assertEquals("consectetur", resultMap.get("var_out_test_3")); }