use of de.prob.prolog.term.CompoundPrologTerm 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.CompoundPrologTerm in project prob2 by bendisposto.
the class ProBPreferenceTest method test.
@Test
public void test() {
VariablePrologTerm typeAwesome = new VariablePrologTerm("TypeAwesome");
CompoundPrologTerm cpt = new CompoundPrologTerm("cpt", new CompoundPrologTerm("IamAwesome"), typeAwesome, new CompoundPrologTerm("descriptionAwesome"), new CompoundPrologTerm("categoryAwesome"), new CompoundPrologTerm("awesomeDefaultValue"));
ProBPreference a = new ProBPreference(cpt);
assertEquals("IamAwesome", a.name);
assertEquals(typeAwesome, a.type);
assertEquals("descriptionAwesome", a.description);
assertEquals("categoryAwesome", a.category);
assertEquals("awesomeDefaultValue", a.defaultValue);
assertEquals("IamAwesome(cat. categoryAwesome, type TypeAwesome, default awesomeDefaultValue) descriptionAwesome", a.toString());
CompoundPrologTerm cpt2 = new CompoundPrologTerm("cpt", new CompoundPrologTerm("IamAwesome"), typeAwesome, new CompoundPrologTerm("descriptionAwesome"), new CompoundPrologTerm("categoryAwesome"), new CompoundPrologTerm("awesomeDefaultValue", new CompoundPrologTerm("I"), new CompoundPrologTerm(" am"), new CompoundPrologTerm(" not"), new CompoundPrologTerm(" simple.")));
a = new ProBPreference(cpt2);
assertEquals("IamAwesome", a.name);
assertEquals(typeAwesome, a.type);
assertEquals("descriptionAwesome", a.description);
assertEquals("categoryAwesome", a.category);
assertEquals("awesomeDefaultValue('I',' am',' not',' simple.')", a.defaultValue);
}
use of de.prob.prolog.term.CompoundPrologTerm 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.CompoundPrologTerm 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.CompoundPrologTerm 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