use of de.prob.prolog.term.PrologTerm 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.PrologTerm in project prob2 by bendisposto.
the class SetPreferenceCommandTest method testWriteCommand.
@Test
public void testWriteCommand() {
StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
SetPreferenceCommand command = new SetPreferenceCommand("foo", "bar");
command.writeCommand(prologTermOutput);
prologTermOutput.fullstop().flush();
Collection<PrologTerm> sentences = prologTermOutput.getSentences();
PrologTerm t = sentences.iterator().next();
assertNotNull(t);
assertTrue(t instanceof CompoundPrologTerm);
assertEquals("set_eclipse_preference", t.getFunctor());
assertEquals(2, t.getArity());
PrologTerm argument1 = t.getArgument(1);
assertTrue(argument1.isAtom());
assertEquals(argument1.toString(), "foo");
PrologTerm argument2 = t.getArgument(2);
assertTrue(argument2.isAtom());
assertEquals(argument2.toString(), "bar");
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetErrorsCommandTest method testWriteCommand.
@Test
public void testWriteCommand() {
StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
GetErrorsCommand command = new GetErrorsCommand();
command.writeCommand(prologTermOutput);
prologTermOutput.fullstop().flush();
Collection<PrologTerm> sentences = prologTermOutput.getSentences();
PrologTerm next = sentences.iterator().next();
assertNotNull(next);
assertTrue(next instanceof CompoundPrologTerm);
CompoundPrologTerm t = (CompoundPrologTerm) next;
assertEquals("get_error_messages", t.getFunctor());
assertEquals(2, t.getArity());
PrologTerm argument = t.getArgument(1);
assertTrue(argument.isVariable());
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetPreferencesCommandTest method testWriteCommand.
@Test
public void testWriteCommand() {
StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
command.writeCommand(prologTermOutput);
prologTermOutput.fullstop().flush();
Collection<PrologTerm> sentences = prologTermOutput.getSentences();
PrologTerm t = sentences.iterator().next();
assertNotNull(t);
assertTrue(t instanceof CompoundPrologTerm);
assertEquals("list_all_eclipse_preferences", t.getFunctor());
assertEquals(1, t.getArity());
PrologTerm argument = t.getArgument(1);
assertTrue(argument.isVariable());
}
use of de.prob.prolog.term.PrologTerm 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");
}
Aggregations