Search in sources :

Example 1 with RulesChecker

use of de.prob.model.brules.RulesChecker in project prob2 by bendisposto.

the class RulesCheckerTest method testExecuteAllOperations.

@Test
public void testExecuteAllOperations() throws IOException {
    StateSpace s = api.brules_load(dir + "RulesMachineExample.rmch");
    Trace trace = new Trace(s);
    RulesChecker rulesChecker = new RulesChecker(trace);
    rulesChecker.init();
    rulesChecker.executeAllOperations();
    for (Entry<AbstractOperation, OperationStatus> entry : rulesChecker.getOperationStates().entrySet()) {
        OperationStatus state = entry.getValue();
        if (entry.getKey().getName().equals("RULE_BasedOnRuleWithViolations")) {
            assertEquals(RuleStatus.NOT_CHECKED, state);
        } else {
            assertTrue(state.isExecuted());
        }
    }
}
Also used : Trace(de.prob.statespace.Trace) StateSpace(de.prob.statespace.StateSpace) AbstractOperation(de.be4.classicalb.core.parser.rules.AbstractOperation) OperationStatus(de.prob.model.brules.OperationStatus) RulesChecker(de.prob.model.brules.RulesChecker) Test(org.junit.Test)

Example 2 with RulesChecker

use of de.prob.model.brules.RulesChecker in project prob2 by bendisposto.

the class RulesCheckerTest method testExecuteOperation.

@Test
public void testExecuteOperation() throws IOException {
    StateSpace s = api.brules_load(dir + "RulesMachineExample.rmch");
    RulesChecker checker = new RulesChecker(new Trace(s));
    boolean possible = checker.executeOperationAndDependencies("RULE_BasedOnValue1");
    assertEquals(true, possible);
    assertEquals(RuleStatus.FAIL, checker.getOperationState("RULE_BasedOnValue1"));
    assertEquals(RuleStatus.NOT_CHECKED, checker.getOperationState("RULE_WithViolations"));
    checker.executeOperationAndDependencies("RULE_WithViolations");
    assertEquals(RuleStatus.FAIL, checker.getOperationState("RULE_WithViolations"));
    boolean possible2 = checker.executeOperationAndDependencies("RULE_BasedOnRuleWithViolations");
    assertEquals(false, possible2);
    assertEquals(RuleStatus.NOT_CHECKED, checker.getOperationState("RULE_BasedOnRuleWithViolations"));
}
Also used : Trace(de.prob.statespace.Trace) StateSpace(de.prob.statespace.StateSpace) RulesChecker(de.prob.model.brules.RulesChecker) Test(org.junit.Test)

Aggregations

RulesChecker (de.prob.model.brules.RulesChecker)2 StateSpace (de.prob.statespace.StateSpace)2 Trace (de.prob.statespace.Trace)2 Test (org.junit.Test)2 AbstractOperation (de.be4.classicalb.core.parser.rules.AbstractOperation)1 OperationStatus (de.prob.model.brules.OperationStatus)1