use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class LoadBProjectCommandTest method testWriteCommand.
@Test
public void testWriteCommand() throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
URL resource = classLoader.getResource("examples/scheduler.mch");
File f = new File(resource.toURI());
StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
ClassicalBFactory factory = new ClassicalBFactory(null);
BParser bparser = new BParser();
Start ast = factory.parseFile(f, bparser);
RecursiveMachineLoader rml = factory.parseAllMachines(ast, f.getParent(), f, bparser.getContentProvider(), bparser);
LoadBProjectCommand command = new LoadBProjectCommand(rml, f);
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("load_classical_b_from_list_of_facts", t.getFunctor());
assertEquals(2, t.getArity());
PrologTerm argument = t.getArgument(2);
assertTrue(argument.isList());
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetStateBasedErrorsCommandTest method testErrorProcessResult2.
@Test(expected = ResultParserException.class)
public void testErrorProcessResult2() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get("Errors")).thenReturn(new CompoundPrologTerm("foobar"));
GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
command.processResult(map);
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetStateBasedErrorsCommandTest method testErrorProcessResult1.
@Test(expected = ResultParserException.class)
public void testErrorProcessResult1() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get("Errors")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("foobar")));
GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
command.processResult(map);
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetErrorsCommandTest method testProcessResults.
@Test
public void testProcessResults() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get(anyString())).thenReturn(new ListPrologTerm(new CompoundPrologTerm("foobar")));
GetErrorsCommand command = new GetErrorsCommand();
command.processResult(map);
List<String> errors = command.getErrors();
assertEquals("foobar", errors.get(0));
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetPreferencesCommandTest method testProcessResultsFail.
@Test(expected = ResultParserException.class)
public void testProcessResultsFail() {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
when(map.get(anyString())).thenReturn(new ListPrologTerm(new CompoundPrologTerm("blah blah blah")));
GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
command.processResult(map);
}
Aggregations