Search in sources :

Example 86 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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);
}
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)

Example 87 with CompoundPrologTerm

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

Example 88 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) 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 89 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project prob2 by bendisposto.

the class GetPreferencesCommandTest method testProcessResultsFail2.

@Test(expected = ResultParserException.class)
public void testProcessResultsFail2() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get(anyString())).thenReturn(new CompoundPrologTerm("blah blah blah"));
    GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
    command.processResult(map);
}
Also used : 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 90 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project prob2 by bendisposto.

the class GetOperationsWithTimeoutTest method testWriteCommand.

@Test
public void testWriteCommand() {
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    GetOperationsWithTimeout command = new GetOperationsWithTimeout("state");
    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("op_timeout_occurred", t.getFunctor());
    assertEquals(2, t.getArity());
    PrologTerm argument = t.getArgument(1);
    assertTrue(argument.isAtom());
    PrologTerm argument2 = t.getArgument(2);
    assertTrue(argument2.isVariable());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) 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

CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)90 PrologTerm (de.prob.prolog.term.PrologTerm)79 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)74 Test (org.junit.Test)62 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)8 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)7 ClassicalB (de.prob.animator.domainobjects.ClassicalB)6 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)6 EventB (de.prob.animator.domainobjects.EventB)5 Transition (de.prob.statespace.Transition)5 ArrayList (java.util.ArrayList)4 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 IEvalElement (de.prob.animator.domainobjects.IEvalElement)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)2 BigInteger (java.math.BigInteger)2 Collections (java.util.Collections)2 BParser (de.be4.classicalb.core.parser.BParser)1