Search in sources :

Example 16 with ListPrologTerm

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);
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Transition(de.prob.statespace.Transition) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm)

Example 17 with ListPrologTerm

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());
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) StateError(de.prob.animator.domainobjects.StateError) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Example 18 with ListPrologTerm

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);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) StateError(de.prob.animator.domainobjects.StateError) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Example 19 with ListPrologTerm

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");
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) ProBPreference(de.prob.animator.domainobjects.ProBPreference) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 20 with ListPrologTerm

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));
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Aggregations

ListPrologTerm (de.prob.prolog.term.ListPrologTerm)38 PrologTerm (de.prob.prolog.term.PrologTerm)33 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)27 Test (org.junit.Test)11 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)6 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)4 ArrayList (java.util.ArrayList)4 Transition (de.prob.statespace.Transition)3 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)2 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 EvalResult (de.prob.animator.domainobjects.EvalResult)2 IEvalElement (de.prob.animator.domainobjects.IEvalElement)2 StateError (de.prob.animator.domainobjects.StateError)2 HashMap (java.util.HashMap)2 List (java.util.List)2 DotEdge (de.prob.animator.domainobjects.DotEdge)1 DotNode (de.prob.animator.domainobjects.DotNode)1 ProBPreference (de.prob.animator.domainobjects.ProBPreference)1 ASTCategory (de.prob.animator.prologast.ASTCategory)1 ASTFormula (de.prob.animator.prologast.ASTFormula)1