Search in sources :

Example 11 with Verifier

use of org.drools.verifier.Verifier 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();
}
Also used : ClassObjectFilter(org.kie.api.runtime.ClassObjectFilter) VerifierBuilder(org.drools.verifier.builder.VerifierBuilder) Overlap(org.drools.verifier.report.components.Overlap) Verifier(org.drools.verifier.Verifier) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with Verifier

use of org.drools.verifier.Verifier 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();
}
Also used : Subsumption(org.drools.verifier.report.components.Subsumption) ClassObjectFilter(org.kie.api.runtime.ClassObjectFilter) Redundancy(org.drools.verifier.report.components.Redundancy) VerifierBuilder(org.drools.verifier.builder.VerifierBuilder) Verifier(org.drools.verifier.Verifier) Test(org.junit.Test)

Example 13 with Verifier

use of org.drools.verifier.Verifier 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();
}
Also used : Subsumption(org.drools.verifier.report.components.Subsumption) ClassObjectFilter(org.kie.api.runtime.ClassObjectFilter) VerifierBuilder(org.drools.verifier.builder.VerifierBuilder) Verifier(org.drools.verifier.Verifier) Test(org.junit.Test)

Example 14 with Verifier

use of org.drools.verifier.Verifier in project drools by kiegroup.

the class SubsumptantRestrictionsTest method testVerifierLiteralRestrictionRedundancy4.

@Test
public void testVerifierLiteralRestrictionRedundancy4() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantRestriction4.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));
    // for ( Object object : subsumptionList ) {
    // System.out.println( object );
    // }
    assertEquals(4, subsumptionList.size());
    verifier.dispose();
}
Also used : Subsumption(org.drools.verifier.report.components.Subsumption) ClassObjectFilter(org.kie.api.runtime.ClassObjectFilter) VerifierBuilder(org.drools.verifier.builder.VerifierBuilder) Verifier(org.drools.verifier.Verifier) Test(org.junit.Test)

Example 15 with Verifier

use of org.drools.verifier.Verifier in project drools by kiegroup.

the class SubsumptantRestrictionsTest method testVerifierLiteralRestrictionRedundancy1.

@Test
public void testVerifierLiteralRestrictionRedundancy1() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantRestriction1.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();
}
Also used : Subsumption(org.drools.verifier.report.components.Subsumption) ClassObjectFilter(org.kie.api.runtime.ClassObjectFilter) VerifierBuilder(org.drools.verifier.builder.VerifierBuilder) Verifier(org.drools.verifier.Verifier) Test(org.junit.Test)

Aggregations

Verifier (org.drools.verifier.Verifier)19 Test (org.junit.Test)19 VerifierBuilder (org.drools.verifier.builder.VerifierBuilder)18 ClassObjectFilter (org.kie.api.runtime.ClassObjectFilter)12 Subsumption (org.drools.verifier.report.components.Subsumption)11 Ignore (org.junit.Ignore)5 VerifierReport (org.drools.verifier.data.VerifierReport)4 ClassPathResource (org.drools.core.io.impl.ClassPathResource)2 VerifierMessageBase (org.drools.verifier.report.components.VerifierMessageBase)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 DrlParser (org.drools.compiler.compiler.DrlParser)1 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)1 DefaultVerifierConfiguration (org.drools.verifier.DefaultVerifierConfiguration)1 VerifierError (org.drools.verifier.VerifierError)1 ScopesAgendaFilter (org.drools.verifier.builder.ScopesAgendaFilter)1