use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class EquivalentRulesTest method testVerifierLiteralRestrictionRedundancy.
@Test
@Ignore("08-APR-2011 temporally ignoring -Rikkola-")
public void testVerifierLiteralRestrictionRedundancy() throws Exception {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("EquivalentRules.drl", getClass()), ResourceType.DRL);
// for ( VerifierError error : verifier.getMissingClasses() ) {
// System.out.println( error.getMessage() );
// }
assertFalse(verifier.hasErrors());
boolean noProblems = verifier.fireAnalysis();
assertTrue(noProblems);
VerifierReport result = verifier.getResult();
Collection<VerifierMessageBase> warnings = result.getBySeverity(Severity.WARNING);
int counter = 0;
for (VerifierMessageBase message : warnings) {
// System.out.println( message );
if (message.getMessageType().equals(MessageType.EQUIVALANCE)) {
// System.out.println( message );
counter++;
}
}
// Has at least one item.
assertEquals(1, counter);
verifier.dispose();
}
use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class IncoherentRestrictionsTest method testApprovedTrueAndNotTrue.
@Test
public void testApprovedTrueAndNotTrue() {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
// Check that the builder works.
assertFalse(vBuilder.hasErrors());
assertEquals(0, vBuilder.getErrors().size());
String str = "";
str += "package mortgages\n";
str += "rule \"Bankruptcy history\"\n";
str += "salience 10\n";
str += "dialect \"mvel\"\n";
str += "when\n";
str += "Applicant( approved == \"true\" , approved != \"true\" )\n";
str += "then\n";
str += "end";
DefaultVerifierConfiguration conf = new DefaultVerifierConfiguration();
Verifier verifier = VerifierBuilderFactory.newVerifierBuilder().newVerifier(conf);
verifier.addResourcesToVerify(ResourceFactory.newReaderResource(new StringReader(str)), ResourceType.DRL);
assertFalse(verifier.hasErrors());
assertEquals(0, verifier.getErrors().size());
boolean works = verifier.fireAnalysis(new ScopesAgendaFilter(true, ScopesAgendaFilter.VERIFYING_SCOPE_KNOWLEDGE_PACKAGE));
assertTrue(works);
VerifierReport result = verifier.getResult();
assertNotNull(result);
assertEquals(3, result.getBySeverity(Severity.ERROR).size());
assertEquals(1, result.getBySeverity(Severity.WARNING).size());
assertEquals(0, result.getBySeverity(Severity.NOTE).size());
}
Aggregations