Package org.drools.lang.descr

Examples of org.drools.lang.descr.PackageDescr


    public void testStatementOrdering1() throws Exception {
        parseResource( "statement_ordering_1.drl" );
        this.parser.compilation_unit();

        final PackageDescr pkg = this.parser.getPackageDescr();

        assertEquals( 2,
                      pkg.getRules().size() );

        assertEquals( "foo",
                      ((RuleDescr) pkg.getRules().get( 0 )).getName() );
        assertEquals( "bar",
                      ((RuleDescr) pkg.getRules().get( 1 )).getName() );

        assertEquals( 2,
                      pkg.getFunctions().size() );

        assertEquals( "cheeseIt",
                      ((FunctionDescr) pkg.getFunctions().get( 0 )).getName() );
        assertEquals( "uncheeseIt",
                      ((FunctionDescr) pkg.getFunctions().get( 1 )).getName() );

        assertEquals( 4,
                      pkg.getImports().size() );
        assertEquals( "im.one",
                      ((ImportDescr) pkg.getImports().get( 0 )).getTarget() );
        assertEquals( "im.two",
                      ((ImportDescr) pkg.getImports().get( 1 )).getTarget() );
        assertEquals( "im.three",
                      ((ImportDescr) pkg.getImports().get( 2 )).getTarget() );
        assertEquals( "im.four",
                      ((ImportDescr) pkg.getImports().get( 3 )).getTarget() );

        assertFalse( this.parser.hasErrors() );
    }
View Full Code Here


        parseResource( "rule_names_number_prefix.drl" ).compilation_unit();

        assertFalse( this.parser.getErrors().toString(),
                     this.parser.hasErrors() );

        final PackageDescr pkg = this.parser.getPackageDescr();

        assertEquals( 2,
                      pkg.getRules().size() );

        assertEquals( "1. Do Stuff!",
                      ((RuleDescr) pkg.getRules().get( 0 )).getName() );
        assertEquals( "2. Do More Stuff!",
                      ((RuleDescr) pkg.getRules().get( 1 )).getName() );
    }
View Full Code Here

    public void testQualifiedClassname() throws Exception {
        parseResource( "qualified_classname.drl" ).compilation_unit();

        assertFalse( this.parser.hasErrors() );

        final PackageDescr pkg = this.parser.getPackageDescr();
        final RuleDescr rule = (RuleDescr) pkg.getRules().get( 0 );

        final PatternDescr p = (PatternDescr) rule.getLhs().getDescrs().get( 0 );

        assertEquals( "com.cheeseco.Cheese",
                      p.getObjectType() );
View Full Code Here

        }

        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        final PackageDescr pack = parser.getPackageDescr();
        assertEquals( 1,
                      pack.getRules().size() );
        final RuleDescr rule = (RuleDescr) pack.getRules().get( 0 );
        assertEquals( 1,
                      rule.getLhs().getDescrs().size() );

        final PatternDescr outPattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        final AccumulateDescr accum = (AccumulateDescr) outPattern.getSource();
View Full Code Here

        parser.compilation_unit();

        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        final PackageDescr pack = parser.getPackageDescr();
        assertEquals( 1,
                      pack.getRules().size() );
        final RuleDescr rule = (RuleDescr) pack.getRules().get( 0 );
        assertEquals( 1,
                      rule.getLhs().getDescrs().size() );

        final PatternDescr outPattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        final AccumulateDescr accum = (AccumulateDescr) outPattern.getSource();
View Full Code Here

            System.err.println( parser.getErrorMessages() );
        }

        assertFalse( parser.hasErrors() );

        final PackageDescr pack = parser.getPackageDescr();
        assertEquals( 1,
                      pack.getRules().size() );
        final RuleDescr rule = (RuleDescr) pack.getRules().get( 0 );
        assertEquals( 1,
                      rule.getLhs().getDescrs().size() );

        final PatternDescr outPattern = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        final CollectDescr collect = (CollectDescr) outPattern.getSource();
View Full Code Here

        parser.compilation_unit();

        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        final PackageDescr pack = parser.getPackageDescr();
        assertEquals( 1,
                      pack.getRules().size() );
        final RuleDescr rule = (RuleDescr) pack.getRules().get( 0 );
        assertEquals( 1,
                      rule.getLhs().getDescrs().size() );

        final ForallDescr forall = (ForallDescr) rule.getLhs().getDescrs().get( 0 );
View Full Code Here

        this.parser.compilation_unit();

        assertFalse( this.parser.getErrorMessages().toString(),
                     this.parser.hasErrors() );

        final PackageDescr pkg = this.parser.getPackageDescr();
        assertEquals( "org.drools",
                      pkg.getName() );
        assertEquals( 1,
                      pkg.getGlobals().size() );
        assertEquals( 3,
                      pkg.getRules().size() );

        final RuleDescr rule1 = (RuleDescr) pkg.getRules().get( 0 );
        assertEquals( 2,
                      rule1.getLhs().getDescrs().size() );

        final RuleDescr query1 = (RuleDescr) pkg.getRules().get( 1 );
        assertEquals( 3,
                      query1.getLhs().getDescrs().size() );

        final RuleDescr rule2 = (RuleDescr) pkg.getRules().get( 2 );
        assertEquals( 2,
                      rule2.getLhs().getDescrs().size() );
    }
View Full Code Here

        this.parser.compilation_unit();

        assertFalse( this.parser.getErrorMessages().toString(),
                     this.parser.hasErrors() );

        final PackageDescr pkg = this.parser.getPackageDescr();
        assertEquals( "org.drools",
                      pkg.getName() );
        assertEquals( 1,
                      pkg.getRules().size() );

        final RuleDescr rule1 = (RuleDescr) pkg.getRules().get( 0 );
        assertEquals( 1,
                      rule1.getLhs().getDescrs().size() );
    }
View Full Code Here

        }

        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );

        final PackageDescr pack = parser.getPackageDescr();
        assertEquals( 1,
                      pack.getRules().size() );
        final RuleDescr rule = (RuleDescr) pack.getRules().get( 0 );
        assertEquals( 1,
                      rule.getLhs().getDescrs().size() );

        final PatternDescr out = (PatternDescr) rule.getLhs().getDescrs().get( 0 );
        final AccumulateDescr accum = (AccumulateDescr) out.getSource();
View Full Code Here

TOP

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

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.