Package org.drools.verifier.components

Examples of org.drools.verifier.components.SubPattern


                                                                         "" );

        Redundancy redundancy = new Redundancy( left,
                                                right );

        SubPattern possibility = new SubPattern( pattern,
                                                 0 );
        possibility.add( left );
        possibility.add( right );

        objects.add( left );
        objects.add( right );
        objects.add( redundancy );
        objects.add( possibility );
View Full Code Here


        VerifierRule rule = VerifierComponentMockFactory.createRule1();
        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        Collection<Object> objects = new ArrayList<Object>();
        SubPattern left = new SubPattern( pattern,
                                          0 );

        SubPattern right = new SubPattern( pattern,
                                           1 );

        Redundancy redundancy = new Redundancy( left,
                                                right );
View Full Code Here

                                                               "" );
        Restriction r2 = LiteralRestriction.createRestriction( pattern1,
                                                               "" );
        Incompatibility i1 = new Incompatibility( r1,
                                                  r2 );
        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        pp1.add( r1 );
        pp1.add( r2 );

        Restriction r3 = new VariableRestriction( pattern1 );
        Restriction r4 = new VariableRestriction( pattern1 );
        Incompatibility i2 = new Incompatibility( r1,
                                                  r2 );
        SubPattern pp2 = new SubPattern( pattern1,
                                         1 );
        pp2.add( r1 );
        pp2.add( r2 );

        // This pattern does not have an error.
        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        Restriction r5 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        Restriction r6 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        SubPattern pp3 = new SubPattern( pattern2,
                                         0 );
        pp3.add( r5 );
        pp3.add( r6 );

        Restriction r7 = new VariableRestriction( pattern2 );
        Restriction r8 = new VariableRestriction( pattern2 );
        Incompatibility i4 = new Incompatibility( r7,
                                                  r8 );
        SubPattern pp4 = new SubPattern( pattern2,
                                         1 );
        pp4.add( r7 );
        pp4.add( r8 );

        data.add( VerifierComponentMockFactory.createRule1() );

        data.add( pattern1 );
        data.add( r1 );
View Full Code Here

        // This rule has an error.
        VerifierRule rule1 = VerifierComponentMockFactory.createRule1();
        Pattern pattern1 = VerifierComponentMockFactory.createPattern1();

        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern1,
                                         1 );
        Incompatibility i1 = new Incompatibility( pp1,
                                                  pp2 );
        SubRule rp1 = new SubRule( rule1,
                                   0 );
        rp1.add( pp1 );
        rp1.add( pp2 );

        SubPattern pp3 = new SubPattern( pattern1,
                                         2 );
        SubPattern pp4 = new SubPattern( pattern1,
                                         3 );
        Incompatibility i2 = new Incompatibility( pp1,
                                                  pp2 );
        SubRule rp2 = new SubRule( rule1,
                                   1 );
        rp2.add( pp1 );
        rp2.add( pp2 );

        // This pattern does not have an error.
        VerifierRule rule2 = VerifierComponentMockFactory.createRule2();
        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        SubPattern pp5 = new SubPattern( pattern2,
                                         0 );
        SubPattern pp6 = new SubPattern( pattern2,
                                         1 );
        SubRule rp3 = new SubRule( rule2,
                                   2 );
        rp3.add( pp5 );
        rp3.add( pp6 );

        SubPattern pp7 = new SubPattern( pattern2,
                                         2 );
        SubPattern pp8 = new SubPattern( pattern2,
                                         3 );
        Incompatibility i4 = new Incompatibility( pp7,
                                                  pp8 );
        SubRule rp4 = new SubRule( rule2,
                                   3 );
View Full Code Here

        List<Restriction> result2 = new ArrayList<Restriction>();
        result2.add( r3 );
        result2.add( r4 );

        Object[] possibilies = list.get( 0 ).getItems().toArray();
        SubPattern p1 = (SubPattern) possibilies[0];
        SubPattern p2 = (SubPattern) possibilies[1];

        /*
         * Order may change but it doesn't matter.
         */
        if ( p1.getItems().containsAll( result ) ) {
            assertTrue( p2.getItems().containsAll( result2 ) );
        } else if ( p1.getItems().containsAll( result2 ) ) {
            assertTrue( p2.getItems().containsAll( result ) );
        } else {
            fail( "No items found." );
        }
    }
View Full Code Here

        result.add( r );
        result.add( r2 );

        Set<RuleComponent> set = list.get( 0 ).getItems();
        for ( RuleComponent component : set ) {
            SubPattern possibility = (SubPattern) component;
            assertTrue( possibility.getItems().containsAll( result ) );
        }
    }
View Full Code Here

        Collection<VerifierComponent> all = verifierData.getAll();

        assertNotNull(all);

        SubPattern test1SubPattern = null;
        SubPattern test2SubPattern = null;
        SubRule test1SubRule = null;
        SubRule test2SubRule = null;

        for (VerifierComponent verifierComponent : all) {
            //            System.out.println( verifierComponent );

          System.out.println( "-" + verifierComponent);
          if(verifierComponent.getDescr()!=null)
          System.out.println(" \n\t\t => " + verifierComponent.getDescr().getLine() + ":" + + verifierComponent.getDescr().getEndLine() + " " + verifierComponent.getDescr().getText());
          else
            System.out.println(" \n\t\t => null for " + verifierComponent.getClass().getSimpleName());

         
            if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) {
                SubPattern subPattern = (SubPattern) verifierComponent;
                if ("Test 1".equals(subPattern.getRuleName())) {
                    assertNull(test1SubPattern);
                    test1SubPattern = subPattern;
                } else if ("Test 2".equals(subPattern.getRuleName())) {
                    assertNull(test2SubPattern);
                    test2SubPattern = subPattern;
                }
            }
            if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_RULE)) {
View Full Code Here

    }

    private void createPatternPossibilities() {
        List<Set<VerifierComponent>> lists = patternSolver.getPossibilityLists();
        if ( lists.size() == 0 ) {
            SubPattern subPattern = newSubPattern();

            ruleSolver.add( subPattern );
            subPatterns.add( subPattern );
        } else {

            for ( Set<VerifierComponent> list : lists ) {
                SubPattern subPattern = newSubPattern();

                for ( VerifierComponent descr : list ) {
                    subPattern.add( (PatternComponent) descr );
                }

                ruleSolver.add( subPattern );
                subPatterns.add( subPattern );
            }
View Full Code Here

            }
        }
    }

    private SubPattern newSubPattern() {
        SubPattern subPattern = new SubPattern( patternSolver.getPattern(),
                                                subPatternIndex++ );

        return subPattern;
    }
View Full Code Here

TOP

Related Classes of org.drools.verifier.components.SubPattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.