Search in sources :

Example 1 with Subsumption

use of org.drools.verifier.report.components.Subsumption in project drools by kiegroup.

the class SubsumptantSubPatternsTest method testSubpatternSubsumption4.

/**
 * Patterns that use from
 *
 * @throws Exception
 */
@Test
@Ignore
public void testSubpatternSubsumption4() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantSubPatterns4.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));
    int count = 0;
    for (Object object : subsumptionList) {
        // System.out.println( " * " + ((Subsumption) object) );
        if (((VerifierComponent) ((Subsumption) object).getLeft()).getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
            count++;
        }
    }
    assertEquals(1, count);
    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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with Subsumption

use of org.drools.verifier.report.components.Subsumption in project drools by kiegroup.

the class SubsumptantSubPatternsTest method testSubpatternSubsumption5.

/**
 * Different sources
 *
 * @throws Exception
 */
@Test
public void testSubpatternSubsumption5() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantSubPatterns5.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));
    int count = 0;
    for (Object object : subsumptionList) {
        // System.out.println( " * " + ((Subsumption) object) );
        if (((VerifierComponent) ((Subsumption) object).getLeft()).getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
            count++;
        }
    }
    assertEquals(8, count);
    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 3 with Subsumption

use of org.drools.verifier.report.components.Subsumption in project drools by kiegroup.

the class SubsumptantSubPatternsTest method testSubpatternSubsumption1.

@Test
public void testSubpatternSubsumption1() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantSubPatterns1.drl", getClass()), ResourceType.DRL);
    // for ( VerifierError error : verifier.getMissingClasses() ) {
    // System.out.println( error.getMessage() );
    // }
    assertFalse(verifier.hasErrors());
    boolean noProblems = verifier.fireAnalysis();
    if (!noProblems) {
        for (VerifierError error : verifier.getErrors()) {
            System.out.println(error.getMessage());
        }
    }
    Collection<? extends Object> subsumptionList = ((VerifierImpl) verifier).getKnowledgeSession().getObjects(new ClassObjectFilter(Subsumption.class));
    int count = 0;
    for (Object object : subsumptionList) {
        // System.out.println( " * " + ((Subsumption) object) );
        if (((VerifierComponent) ((Subsumption) object).getLeft()).getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
            // System.out.println( " ** " + ((SubPattern) ((Subsumption) object).getLeft()).getItems() + " - " + ((SubPattern) ((Subsumption) object).getRight()).getItems() );
            count++;
        }
    }
    assertEquals(1, count);
    verifier.dispose();
}
Also used : VerifierError(org.drools.verifier.VerifierError) 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 4 with Subsumption

use of org.drools.verifier.report.components.Subsumption in project drools by kiegroup.

the class SubsumptantSubPatternsTest method testSubpatternSubsumption2.

/**
 * Empty pattern
 *
 * @throws Exception
 */
@Test
public void testSubpatternSubsumption2() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantSubPatterns2.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));
    int count = 0;
    for (Object object : subsumptionList) {
        // System.out.println( " * " + ((Subsumption) object) );
        if (((VerifierComponent) ((Subsumption) object).getLeft()).getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
            count++;
        }
    }
    assertEquals(1, count);
    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 5 with Subsumption

use of org.drools.verifier.report.components.Subsumption in project drools by kiegroup.

the class SubsumptantSubRulesTest method testSubruleSubsumption1.

@Test
public void testSubruleSubsumption1() throws Exception {
    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
    Verifier verifier = vBuilder.newVerifier();
    verifier.addResourcesToVerify(ResourceFactory.newClassPathResource("SubsumptantSubRules1.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));
    int count = 0;
    for (Object object : subsumptionList) {
        // System.out.println( " * " + ((Subsumption) object) );
        if (((VerifierComponent) ((Subsumption) object).getLeft()).getVerifierComponentType().equals(VerifierComponentType.SUB_RULE)) {
            // System.out.println( " ** " + ((SubRule) ((Subsumption) object).getLeft()).getItems() + " - " + ((SubRule) ((Subsumption) object).getRight()).getItems() );
            count++;
        }
    }
    assertEquals(2, count);
    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)6 VerifierBuilder (org.drools.verifier.builder.VerifierBuilder)6 Subsumption (org.drools.verifier.report.components.Subsumption)6 Test (org.junit.Test)6 ClassObjectFilter (org.kie.api.runtime.ClassObjectFilter)6 VerifierError (org.drools.verifier.VerifierError)1 Ignore (org.junit.Ignore)1