diff --git a/de.cognicrypt.testgenerator/src/de/cognicrypt/testgenerator/generator/ConstraintResolver.java b/de.cognicrypt.testgenerator/src/de/cognicrypt/testgenerator/generator/ConstraintResolver.java index 7a73041..f1e11b2 100644 --- a/de.cognicrypt.testgenerator/src/de/cognicrypt/testgenerator/generator/ConstraintResolver.java +++ b/de.cognicrypt.testgenerator/src/de/cognicrypt/testgenerator/generator/ConstraintResolver.java @@ -4,6 +4,7 @@ import java.security.SecureRandom; import java.util.AbstractMap.SimpleEntry; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.stream.Collectors; @@ -82,6 +83,10 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry para } } String secureInt = ""; + //TODO: need to understand what is secureInt + if(value == 0) { + secureInt = "0"; + }else { switch (comp.getOperator()) { case g: case ge: @@ -103,7 +108,7 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry para case eq: default: break; - } + }} return secureInt; } } else if (constraint instanceof CrySLPredicate && "instanceOf".equals(((CrySLPredicate) constraint).getPredName())) { @@ -116,8 +121,18 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry para LogOps operator = crySLConstraint.getOperator(); ISLConstraint left = crySLConstraint.getLeft(); ISLConstraint right = crySLConstraint.getRight(); - Entry leftAlternative = new SimpleEntry(left.getInvolvedVarNames().iterator().next(), parameter.getValue()); - Entry rightAlternative = new SimpleEntry(right.getInvolvedVarNames().iterator().next(), parameter.getValue()); + Iterator leftAltiterator = left.getInvolvedVarNames().iterator(); + Entry leftAlternative = null; + if(leftAltiterator.hasNext()) { + leftAlternative = new SimpleEntry(leftAltiterator.next(), parameter.getValue()); + } +// new SimpleEntry(leftAltiterator.next(), parameter.getValue()) + Iterator rightAltiterator = right.getInvolvedVarNames().iterator(); + + Entry rightAlternative = null; + if (rightAltiterator.hasNext()) { + rightAlternative = new SimpleEntry(rightAltiterator.next(), parameter.getValue()); + } if (operator == LogOps.and) { if (left.getInvolvedVarNames().contains(parVarName)) { @@ -156,13 +171,19 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry para if (!leftResult.isEmpty()) { return leftResult; } else { - return resolveCrySLConstraint(rule, rightAlternative, right, onlyEval); + if (rightAlternative != null) { + return resolveCrySLConstraint(rule, rightAlternative, right, onlyEval); + } + } } } else if (operator == LogOps.implies) { - if (!right.getInvolvedVarNames().contains(parVarName) || resolveCrySLConstraint(rule, leftAlternative, left, true).isEmpty()) { - return ""; + if (leftAlternative != null) { + if (!right.getInvolvedVarNames().contains(parVarName) || resolveCrySLConstraint(rule, leftAlternative, left, true).isEmpty()) { + return ""; + } } + return resolveCrySLConstraint(rule, parameter, right); } else { return ""; // invalid operator