use of de.prob.prolog.term.ListPrologTerm in project prob2 by bendisposto.
the class ExecuteUntilCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
ListPrologTerm trace = BindingGenerator.getList(bindings.get(TRACE_VARIABLE));
result = bindings.get(RESULT_VARIABLE);
for (PrologTerm term : trace) {
CompoundPrologTerm t = BindingGenerator.getCompoundTerm(term, 4);
Transition operation = Transition.createTransitionFromCompoundPrologTerm(statespace, t);
resultTrace.add(operation);
}
}
use of de.prob.prolog.term.ListPrologTerm in project prob2 by bendisposto.
the class GetStateBasedErrorsCommandTest method testProcessResult.
@Test
public void testProcessResult() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get("Errors")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("error", new CompoundPrologTerm("foo"), new CompoundPrologTerm("bar"), new CompoundPrologTerm("baz"))));
GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
command.processResult(map);
Collection<StateError> coll = command.getResult();
StateError se = coll.iterator().next();
assertEquals("foo", se.getEvent());
assertEquals("bar", se.getShortDescription());
assertEquals("baz", se.getLongDescription());
}
use of de.prob.prolog.term.ListPrologTerm in project prob2 by bendisposto.
the class GetStateBasedErrorsCommandTest method testProcessResultEmpty.
@Test
public void testProcessResultEmpty() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get("Errors")).thenReturn(new ListPrologTerm());
GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
command.processResult(map);
Collection<StateError> coll = command.getResult();
assertEquals(Collections.emptyList(), coll);
}
use of de.prob.prolog.term.ListPrologTerm in project prob2 by bendisposto.
the class GetPreferencesCommandTest method testProcessResults.
@Test
public void testProcessResults() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get("Prefs")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("preference", new CompoundPrologTerm("tinker"), new CompoundPrologTerm("tailor"), new CompoundPrologTerm("soldier"), new CompoundPrologTerm("sailor"), new CompoundPrologTerm("foo")), new CompoundPrologTerm("preference", new CompoundPrologTerm("richman"), new CompoundPrologTerm("poorman"), new CompoundPrologTerm("beggarman"), new CompoundPrologTerm("thief"), new CompoundPrologTerm("bar"))));
GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
command.processResult(map);
List<ProBPreference> prefs = command.getPreferences();
assertEquals(prefs.size(), 2);
ProBPreference pref1 = prefs.get(0);
assertEquals(pref1.name, "tinker");
assertEquals(pref1.type.toString(), "tailor");
assertEquals(pref1.description, "soldier");
assertEquals(pref1.category, "sailor");
assertEquals(pref1.defaultValue, "foo");
ProBPreference pref2 = prefs.get(1);
assertEquals(pref2.name, "richman");
assertEquals(pref2.type.toString(), "poorman");
assertEquals(pref2.description, "beggarman");
assertEquals(pref2.category, "thief");
assertEquals(pref2.defaultValue, "bar");
}
use of de.prob.prolog.term.ListPrologTerm in project prob2 by bendisposto.
the class GetOperationsWithTimeoutTest method testProcessResults.
@Test
public void testProcessResults() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get("TO")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("foobar"), new CompoundPrologTerm("bliblablub")));
GetOperationsWithTimeout command = new GetOperationsWithTimeout("state");
command.processResult(map);
List<String> list = command.getTimeouts();
assertEquals("foobar", list.get(0));
assertEquals("bliblablub", list.get(1));
}
Aggregations