Package org.drools.lang.descr

Examples of org.drools.lang.descr.PatternDescr


        }
        assertFalse( parser.hasErrors() );

        assertEquals( 2,
                      descrs.getDescrs().size() );
        PatternDescr pat = (PatternDescr) descrs.getDescrs().get( 1 );
        FieldConstraintDescr fieldConstr = (FieldConstraintDescr) pat.getConstraint().getDescrs().get( 0 );
        VariableRestrictionDescr restr = (VariableRestrictionDescr) fieldConstr.getRestrictions().get( 0 );

        assertEquals( "not memberOf",
                      restr.getEvaluator() );
        assertEquals( "$cities",
View Full Code Here


                      rule.getName() );
        assertEquals( 2,
                      rule.getLhs().getDescrs().size() );

        //The first pattern, with 2 restrictions on a single field (plus a connective)
        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        assertEquals( "Person",
                      pattern.getObjectType() );
        assertEquals( 1,
                      pattern.getConstraint().getDescrs().size() );

        FieldConstraintDescr fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( RestrictionConnectiveDescr.AND,
                      fld.getRestriction().getConnective() );
        assertEquals( 2,
                      fld.getRestrictions().size() );
        assertEquals( "age",
                      fld.getFieldName() );

        LiteralRestrictionDescr lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
        assertEquals( ">",
                      lit.getEvaluator() );
        assertEquals( "30",
                      lit.getText() );

        lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 1 );
        assertEquals( "<",
                      lit.getEvaluator() );
        assertEquals( "40",
                      lit.getText() );

        //the second col, with 2 fields, the first with 2 restrictions, the second field with one
        pattern = (PatternDescr) rule.getLhs().getDescrs().get( 1 );
        assertEquals( "Vehicle",
                      pattern.getObjectType() );
        assertEquals( 2,
                      pattern.getConstraint().getDescrs().size() );

        fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( "type",
                      fld.getFieldName() );
        assertEquals( 1,
                      fld.getRestrictions().size() );

        RestrictionConnectiveDescr or = (RestrictionConnectiveDescr) fld.getRestrictions().get( 0 );
        assertEquals( RestrictionConnectiveDescr.OR,
                      or.getConnective() );
        assertEquals( 2,
                      or.getRestrictions().size() );

        lit = (LiteralRestrictionDescr) or.getRestrictions().get( 0 );
        assertEquals( "==",
                      lit.getEvaluator() );
        assertEquals( "sedan",
                      lit.getText() );

        lit = (LiteralRestrictionDescr) or.getRestrictions().get( 1 );
        assertEquals( "==",
                      lit.getEvaluator() );
        assertEquals( "wagon",
                      lit.getText() );

        //now the second field
        fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 1 );
        assertEquals( 1,
                      fld.getRestrictions().size() );
        lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
        assertEquals( "<",
                      lit.getEvaluator() );
View Full Code Here

                      rule.getName() );
        assertEquals( 2,
                      rule.getLhs().getDescrs().size() );

        //The first pattern, with 2 restrictions on a single field (plus a connective)
        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        assertEquals( "Person",
                      pattern.getObjectType() );
        assertEquals( 1,
                      pattern.getConstraint().getDescrs().size() );

        FieldConstraintDescr fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( 2,
                      fld.getRestrictions().size() );
        assertEquals( "age",
                      fld.getFieldName() );

        LiteralRestrictionDescr lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
        assertEquals( ">",
                      lit.getEvaluator() );
        assertEquals( "30",
                      lit.getText() );

        lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 1 );
        assertEquals( "<",
                      lit.getEvaluator() );
        assertEquals( "40",
                      lit.getText() );

        //the second col, with 2 fields, the first with 2 restrictions, the second field with one
        pattern = (PatternDescr) rule.getLhs().getDescrs().get( 1 );
        assertEquals( "Vehicle",
                      pattern.getObjectType() );
        assertEquals( 2,
                      pattern.getConstraint().getDescrs().size() );

        fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        assertEquals( 2,
                      fld.getRestrictions().size() );
        lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
        assertEquals( "type",
                      fld.getFieldName() );
        assertEquals( "!=",
                      lit.getEvaluator() );
        assertEquals( "sedan",
                      lit.getText() );

        lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 1 );
        assertEquals( "!=",
                      lit.getEvaluator() );
        assertEquals( "wagon",
                      lit.getText() );

        //now the second field
        fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 1 );
        assertEquals( 1,
                      fld.getRestrictions().size() );
        lit = (LiteralRestrictionDescr) fld.getRestrictions().get( 0 );
        assertEquals( "<",
                      lit.getEvaluator() );
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 2,
                      pattern.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) pattern.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
        fcd = (FieldConstraintDescr) pattern.getDescrs().get( 1 );
        assertEquals( "location",
                      fcd.getFieldName() );
    }
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 1,
                      pattern.getDescrs().size() );
        OrDescr or = (OrDescr) pattern.getDescrs().get( 0 );
        assertEquals( 2,
                      or.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) or.getDescrs().get( 0 );
        assertEquals( "age",
                      fcd.getFieldName() );
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 1,
                      pattern.getDescrs().size() );
        OrDescr or = (OrDescr) pattern.getDescrs().get( 0 );
        assertEquals( 3,
                      or.getDescrs().size() );

        AndDescr and = (AndDescr) or.getDescrs().get( 0 );
        assertEquals( 2,
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 1,
                      pattern.getDescrs().size() );
        OrDescr or1 = (OrDescr) pattern.getDescrs().get( 0 );
        assertEquals( 2,
                      or1.getDescrs().size() );

        AndDescr and1 = (AndDescr) or1.getDescrs().get( 0 );
        assertEquals( 2,
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 1,
                      pattern.getDescrs().size() );
        OrDescr or1 = (OrDescr) pattern.getDescrs().get( 0 );
        assertEquals( 3,
                      or1.getDescrs().size() );

        AndDescr and1 = (AndDescr) or1.getDescrs().get( 0 );
        AndDescr and2 = (AndDescr) or1.getDescrs().get( 1 );
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 1,
                      pattern.getDescrs().size() );

        OrDescr orConstr = (OrDescr) pattern.getDescrs().get( 0 );

        assertEquals( 3,
                      orConstr.getDescrs().size() );

        AndDescr andConstr1 = (AndDescr) orConstr.getDescrs().get( 0 );
View Full Code Here

        final CharStream charStream = new ANTLRStringStream( text );
        final DRLLexer lexer = new DRLLexer( charStream );
        final TokenStream tokenStream = new CommonTokenStream( lexer );
        final DRLParser parser = new DRLParser( tokenStream );

        PatternDescr pattern = (PatternDescr) parser.fact( null );
        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        assertEquals( 1,
                      pattern.getDescrs().size() );
        FieldConstraintDescr fcd = (FieldConstraintDescr) pattern.getDescrs().get( 0 );
        assertEquals( "name",
                      fcd.getFieldName() );

        RestrictionConnectiveDescr or = (RestrictionConnectiveDescr) fcd.getRestrictions().get( 0 );
View Full Code Here

TOP

Related Classes of org.drools.lang.descr.PatternDescr

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.