Package org.drools.verifier.components

Examples of org.drools.verifier.components.SubPattern


        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        /*
         * Working pair
         */
        SubPattern pp1 = new SubPattern( pattern,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern,
                                         1 );

        Restriction r1 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp1.add( r1 );

        Restriction r2 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp2.add( r2 );

        Restriction r3 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp1.add( r3 );

        Restriction r4 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp2.add( r4 );

        Opposites o1 = new Opposites( r1,
                                      r2 );
        Opposites o2 = new Opposites( r3,
                                      r4 );

        /*
         * Pair that doesn't work.
         */
        SubPattern pp3 = new SubPattern( pattern,
                                         2 );
        SubPattern pp4 = new SubPattern( pattern,
                                         3 );

        Restriction r5 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp3.add( r5 );

        Restriction r6 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp4.add( r6 );

        Restriction r7 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp3.add( r7 );

        Restriction r8 = LiteralRestriction.createRestriction( pattern,
                                                               "" );
        pp4.add( r8 );

        Opposites o3 = new Opposites( r5,
                                      r6 );

        data.add( r1 );
View Full Code Here


        saveVerifierComponentAndGet( new ObjectType() );
        saveVerifierComponentAndGet( new RuleOperatorDescr( 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

                                                               "" );
        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( 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

        // 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

        VerifierRule rule1 = VerifierComponentMockFactory.createRule1();
        Pattern pattern1 = VerifierComponentMockFactory.createPattern1();

        SubRule rp1 = new SubRule( rule1,
                                   0 );
        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        AlwaysTrue alwaysTrue1 = new AlwaysTrue( pp1 );
        SubPattern pp2 = new SubPattern( pattern1,
                                         1 );
        AlwaysTrue alwaysTrue2 = new AlwaysTrue( pp2 );

        rp1.add( pp1 );
        rp1.add( pp2 );

        // This rule is okay.
        VerifierRule rule2 = VerifierComponentMockFactory.createRule2();
        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        SubRule rp2 = new SubRule( rule2,
                                   0 );
        SubPattern pp3 = new SubPattern( pattern2,
                                         0 );
        SubPattern pp4 = new SubPattern( pattern2,
                                         1 );
        AlwaysTrue alwaysTrue4 = new AlwaysTrue( pp4 );

        rp2.add( pp3 );
        rp2.add( pp4 );
View Full Code Here

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

        assertNotNull( all );

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

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

            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

        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

        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        /*
         * Working pair
         */
        SubPattern pp1 = new SubPattern( pattern1,
                                         0 );
        SubPattern pp2 = new SubPattern( pattern2,
                                         0 );

        Restriction r1 = LiteralRestriction.createRestriction( pattern1,
                                                               "" );
        pp1.add( r1 );

        Restriction r2 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        pp2.add( r2 );

        Restriction r3 = LiteralRestriction.createRestriction( pattern1,
                                                               "" );
        pp1.add( r3 );

        Restriction r4 = LiteralRestriction.createRestriction( pattern2,
                                                               "" );
        pp2.add( r4 );

        Incompatibility o1 = new Incompatibility( r1,
                                                  r2 );
        Incompatibility o2 = new Incompatibility( r3,
                                                  r4 );

        Pattern pattern3 = VerifierComponentMockFactory.createPattern( 3 );
        Pattern pattern4 = VerifierComponentMockFactory.createPattern( 4 );
        /*
         * Another working pair.
         */
        SubPattern pp3 = new SubPattern( pattern3,
                                         0 );
        SubPattern pp4 = new SubPattern( pattern4,
                                         0 );

        Restriction r5 = LiteralRestriction.createRestriction( pattern3,
                                                               "" );
        pp3.add( r5 );

        Restriction r6 = LiteralRestriction.createRestriction( pattern4,
                                                               "" );
        pp4.add( r6 );

        Restriction r7 = LiteralRestriction.createRestriction( pattern3,
                                                               "" );
        pp3.add( r7 );

        Restriction r8 = LiteralRestriction.createRestriction( pattern4,
                                                               "" );
        pp4.add( r8 );

        Incompatibility o3 = new Incompatibility( r5,
                                                  r6 );

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