use of de.prob.animator.domainobjects.TranslatedEvalResult in project prob2 by bendisposto.
the class RuleResult method transformCounterExamples.
private void transformCounterExamples(AbstractEvalResult abstractEvalResult) {
EvalResult evalCurrent = (EvalResult) abstractEvalResult;
TranslatedEvalResult translatedResult = null;
try {
translatedResult = evalCurrent.translate();
} catch (Exception e) {
/*- fall back solution if the result can not be parsed (e.g. {1,...,1000})
* should not not happen because MAX_DISPLAY_SET is set to -1
* and hence, no truncated terms are delivered by ProBCore
* */
final String message = evalCurrent.getValue().replaceAll("\"", "");
counterExamples.add(new CounterExample(1, message));
return;
}
if (translatedResult.getValue() instanceof de.prob.translator.types.Set) {
de.prob.translator.types.Set set = (de.prob.translator.types.Set) translatedResult.getValue();
for (final BObject object : set) {
if (object instanceof Tuple) {
final Tuple tuple = (Tuple) object;
de.prob.translator.types.Number first = (de.prob.translator.types.Number) tuple.getFirst();
int errorType = first.intValue();
de.prob.translator.types.String second = (de.prob.translator.types.String) tuple.getSecond();
String message = second.getValue();
counterExamples.add(new CounterExample(errorType, message));
} else {
throw new AssertionError();
}
}
} else if (translatedResult.getValue() instanceof de.prob.translator.types.Sequence) {
de.prob.translator.types.Sequence sequence = (de.prob.translator.types.Sequence) translatedResult.getValue();
for (int i = 1; i <= sequence.size(); i++) {
de.prob.translator.types.String value = (de.prob.translator.types.String) sequence.get(i);
String message = value.getValue();
counterExamples.add(new CounterExample(i, message));
}
} else {
// fall back: should not happen
counterExamples.add(new CounterExample(1, evalCurrent.getValue()));
}
}
Aggregations