Package org.drools.verifier.components

Examples of org.drools.verifier.components.SubPattern


        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


        // Check that there is three pattern possibilities and that they contain
        // the right amount of items.
        for ( Object o : testData ) {
            if ( o instanceof SubPattern ) {
                SubPattern pp = (SubPattern) o;
                if ( pp.getItems().size() == 2 ) {

                    patternCount++;
                }
            }
        }
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

        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

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

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

        // This pattern is okay.
        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 );
        Opposites o4 = new Opposites( r7,
                                      r8 );
        SubPattern pp4 = new SubPattern( pattern2,
                                         1 );
        pp4.add( r7 );
        pp4.add( r8 );

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

        VerifierRule rule1 = VerifierComponentMockFactory.createRule1();

        // This pattern is always true.
        Pattern pattern1 = VerifierComponentMockFactory.createPattern1();

        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        AlwaysTrue alwaysTrue1 = new AlwaysTrue( pp1 );

        SubPattern pp2 = new SubPattern( pattern1,
                                         1 );
        AlwaysTrue alwaysTrue2 = new AlwaysTrue( pp2 );

        // This pattern is okay.
        Pattern pattern2 = new Pattern(new PatternDescr("objectType2", "testPattern2" ), rule1 );
        pattern2.setName( "testPattern2" );

        SubPattern pp3 = new SubPattern( pattern2,
                                         0 );

        SubPattern pp4 = new SubPattern( pattern2,
                                         1 );
        AlwaysTrue alwaysTrue4 = new AlwaysTrue( pp4 );

        data.add( rule1 );
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

        saveVerifierComponentAndGet( new ObjectType(new PackageDescr("testPackage1")) );
        saveVerifierComponentAndGet( new RuleOperatorDescr( new AndDescr(), rule,
                                                            OperatorDescrType.AND ) );
        saveVerifierComponentAndGet( new PatternOperatorDescr( pattern,
                                                               OperatorDescrType.AND ) );
        saveVerifierComponentAndGet( new SubPattern( pattern,
                                                     0 ) );
        saveVerifierComponentAndGet( new ReturnValueFieldDescr( pattern ) );
        saveVerifierComponentAndGet( new SubRule( rule,
                                                  0 ) );
        saveVerifierComponentAndGet( new TextConsequence( rule ) );
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.