@Test public void noContaminationTest() { List<Map<String, String>> pipeInputList = new LinkedList<>(); HashMap<String, String> nonEmptyPossibleState = new HashMap<>(); nonEmptyPossibleState.put("var_out_test", "foobar"); pipeInputList.add(nonEmptyPossibleState); RangeExtension rangeExtension = new RangeExtension(); RangeExtension.RangeTag rangeTag = new RangeExtension.RangeTag(); rangeTag.setName("var_out_test_2"); rangeTag.setFrom("1"); rangeTag.setTo("5"); rangeTag.setStep("0.7"); List<Map<String, String>> resultList = rangeExtension.pipelinePossibleStates(rangeTag, pipeInputList); Assert.assertEquals(6, resultList.size()); for (int i = 0; i < 6; i++) { Assert.assertEquals("foobar", resultList.get(i).get("var_out_test")); } }
public List<Map<String, String>> pipelinePossibleStates(RangeTag action, List<Map<String, String>> possibleStateList) { String variable = action.getName(); BigDecimal from = new BigDecimal(action.getFrom()); BigDecimal to = new BigDecimal(action.getTo()); BigDecimal step; if (action.getStep() != null) { step = new BigDecimal(action.getStep()); } else { step = BigDecimal.ONE; } List<BigDecimal> rangeValues = new ArrayList<>(); if (step.signum() == 1) { for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) { rangeValues.add(current); } } else if (step.signum() == -1) { for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) { rangeValues.add(current); } } else { rangeValues.add(from); } List<Map<String, String>> productTemp = new LinkedList<>(); for (Map<String, String> p : possibleStateList) { for (BigDecimal value : rangeValues) { HashMap<String, String> n = new HashMap<>(p); n.put(variable, value.toString()); productTemp.add(n); } } return productTemp; }
RangeExtension implements CustomTagExtension<RangeExtension.RangeTag> { public List<Map<String, String>> pipelinePossibleStates(RangeTag action, List<Map<String, String>> possibleStateList) { String variable = action.getName(); BigDecimal from = new BigDecimal(action.getFrom()); BigDecimal to = new BigDecimal(action.getTo()); BigDecimal step; if (action.getStep() != null) { step = new BigDecimal(action.getStep()); } else { step = BigDecimal.ONE; } List<BigDecimal> rangeValues = new ArrayList<>(); if (step.signum() == 1) { for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) { rangeValues.add(current); } } else if (step.signum() == -1) { for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) { rangeValues.add(current); } } else { rangeValues.add(from); } List<Map<String, String>> productTemp = new LinkedList<>(); for (Map<String, String> p : possibleStateList) { for (BigDecimal value : rangeValues) { HashMap<String, String> n = new HashMap<>(p); n.put(variable, value.toString()); productTemp.add(n); } } return productTemp; } }
RangeExtension implements CustomTagExtension<RangeExtension.RangeTag> { public List<Map<String, String>> pipelinePossibleStates(RangeTag action, List<Map<String, String>> possibleStateList) { String variable = action.getName(); BigDecimal from = new BigDecimal(action.getFrom()); BigDecimal to = new BigDecimal(action.getTo()); BigDecimal step; if (action.getStep() != null) { step = new BigDecimal(action.getStep()); } else { step = BigDecimal.ONE; } List<BigDecimal> rangeValues = new ArrayList<>(); if (step.signum() == 1) { for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) { rangeValues.add(current); } } else if (step.signum() == -1) { for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) { rangeValues.add(current); } } else { rangeValues.add(from); } List<Map<String, String>> productTemp = new LinkedList<>(); for (Map<String, String> p : possibleStateList) { for (BigDecimal value : rangeValues) { HashMap<String, String> n = new HashMap<>(p); n.put(variable, value.toString()); productTemp.add(n); } } return productTemp; }  }
RangeExtension implements CustomTagExtension<RangeExtension.RangeTag> { public List<Map<String, String>> pipelinePossibleStates(RangeTag action, List<Map<String, String>> possibleStateList) { String variable = action.getName(); BigDecimal from = new BigDecimal(action.getFrom()); BigDecimal to = new BigDecimal(action.getTo()); BigDecimal step; if (action.getStep() != null) { step = new BigDecimal(action.getStep()); } else { step = BigDecimal.ONE; } List<BigDecimal> rangeValues = new ArrayList<>(); if (step.signum() == 1) { for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) { rangeValues.add(current); } } else if (step.signum() == -1) { for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) { rangeValues.add(current); } } else { rangeValues.add(from); } List<Map<String, String>> productTemp = new LinkedList<>(); for (Map<String, String> p : possibleStateList) { for (BigDecimal value : rangeValues) { HashMap<String, String> n = new HashMap<>(p); n.put(variable, value.toString()); productTemp.add(n); } } return productTemp; }  Class<RangeTag> getTagActionClass(); String getTagName(); String getTagNameSpace(); List<Map<String, String>> pipelinePossibleStates(RangeTag action,
                                                            List<Map<String, String>> possibleStateList); }
RangeExtension implements CustomTagExtension<RangeExtension.RangeTag> { public List<Map<String, String>> pipelinePossibleStates(RangeTag action, List<Map<String, String>> possibleStateList) { String variable = action.getName(); BigDecimal from = new BigDecimal(action.getFrom()); BigDecimal to = new BigDecimal(action.getTo()); BigDecimal step; if (action.getStep() != null) { step = new BigDecimal(action.getStep()); } else { step = BigDecimal.ONE; } List<BigDecimal> rangeValues = new ArrayList<>(); if (step.signum() == 1) { for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) { rangeValues.add(current); } } else if (step.signum() == -1) { for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) { rangeValues.add(current); } } else { rangeValues.add(from); } List<Map<String, String>> productTemp = new LinkedList<>(); for (Map<String, String> p : possibleStateList) { for (BigDecimal value : rangeValues) { HashMap<String, String> n = new HashMap<>(p); n.put(variable, value.toString()); productTemp.add(n); } } return productTemp; }  Class<RangeTag> getTagActionClass(); String getTagName(); String getTagNameSpace(); List<Map<String, String>> pipelinePossibleStates(RangeTag action,
                                                            List<Map<String, String>> possibleStateList);  }