use of de.prob.model.brules.RuleResults in project prob2 by bendisposto.
the class RulesMachineTest method testSimpleRulesMachine.
@Test
public void testSimpleRulesMachine() throws IOException {
RulesMachineRun rulesMachineRun = startRulesMachineRun(dir + "SimpleRulesMachine.rmch");
assertEquals(false, rulesMachineRun.hasError());
assertTrue(rulesMachineRun.getErrorList().isEmpty());
assertEquals(null, rulesMachineRun.getFirstError());
RuleResults ruleResults = rulesMachineRun.getRuleResults();
ResultSummary summary = ruleResults.getSummary();
// summary is created only once
assertEquals(summary, ruleResults.getSummary());
assertEquals(4, ruleResults.getRuleResultList().size());
RuleResult rule1Result = ruleResults.getRuleResult("Rule1");
assertEquals(RuleStatus.SUCCESS, rule1Result.getRuleState());
RuleOperation rule1Operation = rule1Result.getRuleOperation();
assertEquals("Rule1", rule1Operation.getName());
assertTrue("Should be empty", rule1Result.getNotCheckedDependencies().isEmpty());
RuleResult result2 = ruleResults.getRuleResult("Rule2");
assertEquals(RuleStatus.FAIL, result2.getRuleState());
String message = result2.getCounterExamples().get(0).getMessage();
assertEquals("ERROR2", message);
assertEquals(NOT_CHECKED, ruleResults.getRuleResult("Rule3").getRuleState());
assertEquals("Rule2", ruleResults.getRuleResult("Rule3").getFailedDependencies().get(0));
}
use of de.prob.model.brules.RuleResults in project prob2 by bendisposto.
the class RulesTestUtil method checkRulesMachineRunForConsistency.
public static void checkRulesMachineRunForConsistency(RulesMachineRun rulesMachineRun) {
RulesProject rulesProject = rulesMachineRun.getRulesProject();
RuleResults ruleResults = rulesMachineRun.getRuleResults();
Map<String, RuleResult> ruleResultMap = ruleResults.getRuleResultMap();
for (AbstractOperation abstractOperation : rulesProject.getOperationsMap().values()) {
if (abstractOperation instanceof RuleOperation) {
String ruleName = abstractOperation.getName();
assertTrue(String.format("Rule operation '%s' is not contained in the result map.", ruleName), ruleResultMap.containsKey(ruleName));
RuleResult ruleResult = ruleResultMap.get(ruleName);
if (ruleResult.getRuleState() == RuleStatus.FAIL) {
assertTrue(String.format("No violation found but rule failed: '%s'", ruleName), ruleResult.getNumberOfViolations() > 0);
}
if (ruleResult.getRuleState() == RuleStatus.NOT_CHECKED) {
List<String> notCheckedCauses = ruleResult.getFailedDependencies();
assertTrue(String.format("There is no cause why rule '%s' is not checked.", ruleName), !notCheckedCauses.isEmpty());
}
}
}
}
Aggregations