use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class VerifierTest method testVerifier.
@Test
public void testVerifier() {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
// Check that the builder works.
assertFalse(vBuilder.hasErrors());
assertEquals(0, vBuilder.getErrors().size());
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(new ClassPathResource("Misc3.drl", Verifier.class), ResourceType.DRL);
assertFalse(verifier.hasErrors());
assertEquals(0, verifier.getErrors().size());
boolean works = verifier.fireAnalysis();
assertTrue(works);
VerifierReport result = verifier.getResult();
assertNotNull(result);
assertEquals(0, result.getBySeverity(Severity.ERROR).size());
assertEquals(6, result.getBySeverity(Severity.WARNING).size());
assertEquals(1, result.getBySeverity(Severity.NOTE).size());
}
use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class VerifierTest method testFactTypesFromJar.
@Test
public void testFactTypesFromJar() {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
// Check that the builder works.
assertFalse(vBuilder.hasErrors());
assertEquals(0, vBuilder.getErrors().size());
Verifier verifier = vBuilder.newVerifier();
try {
JarInputStream jar = new JarInputStream(this.getClass().getResourceAsStream("model.jar"));
verifier.addObjectModel(jar);
} catch (IOException e) {
fail(e.getMessage());
}
verifier.addResourcesToVerify(new ClassPathResource("imports.drl", Verifier.class), ResourceType.DRL);
assertFalse(verifier.hasErrors());
assertEquals(0, verifier.getErrors().size());
boolean works = verifier.fireAnalysis();
assertTrue(works);
VerifierReport result = verifier.getResult();
Collection<ObjectType> objectTypes = result.getVerifierData().getAll(VerifierComponentType.OBJECT_TYPE);
assertNotNull(objectTypes);
assertEquals(3, objectTypes.size());
Collection<Field> fields = result.getVerifierData().getAll(VerifierComponentType.FIELD);
assertNotNull(fields);
assertEquals(10, fields.size());
}
use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class OverlappingRestrictionsTest method testOverlap.
// TODO: Add this feature
@Test
@Ignore
public void testOverlap() {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("RestrictionsTest.drl", getClass()), ResourceType.DRL);
assertFalse(verifier.hasErrors());
boolean noProblems = verifier.fireAnalysis();
assertTrue(noProblems);
Collection<? extends Object> overlaps = ((VerifierImpl) verifier).getKnowledgeSession().getObjects(new ClassObjectFilter(Overlap.class));
for (Object object : overlaps) {
System.out.println(object);
}
assertEquals(3, overlaps.size());
verifier.dispose();
}
use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class RedundancyTest method testVerifierLiteralRestrictionRedundancy.
@Test
public void testVerifierLiteralRestrictionRedundancy() throws Exception {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("RedundantRestrictions.drl", getClass()), ResourceType.DRL);
assertFalse(verifier.hasErrors());
boolean noProblems = verifier.fireAnalysis();
assertTrue(noProblems);
Collection<? extends Object> subsumptionList = ((VerifierImpl) verifier).getKnowledgeSession().getObjects(new ClassObjectFilter(Subsumption.class));
Collection<? extends Object> redundancyList = ((VerifierImpl) verifier).getKnowledgeSession().getObjects(new ClassObjectFilter(Redundancy.class));
assertEquals(2, subsumptionList.size());
assertEquals(1, redundancyList.size());
verifier.dispose();
}
use of org.drools.verifier.builder.VerifierBuilder in project drools by kiegroup.
the class SubsumptantRestrictionsTest method testVerifierLiteralRestrictionRedundancy2.
@Test
public void testVerifierLiteralRestrictionRedundancy2() throws Exception {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantRestriction2.drl", getClass()), ResourceType.DRL);
// for ( VerifierError error : verifier.getMissingClasses() ) {
// System.out.println( error.getMessage() );
// }
assertFalse(verifier.hasErrors());
boolean noProblems = verifier.fireAnalysis();
assertTrue(noProblems);
Collection<? extends Object> subsumptionList = ((VerifierImpl) verifier).getKnowledgeSession().getObjects(new ClassObjectFilter(Subsumption.class));
assertEquals(9, subsumptionList.size());
verifier.dispose();
}
Aggregations