Examples of Cheese


Examples of org.drools.Cheese

        final WorkingMemory workingMemory = ruleBase.newStatefulSession();
        final List list = new ArrayList();
        workingMemory.setGlobal( "list",
                                 list );

        final Cheese cheddar = new Cheese( "cheddar",
                                           5 );
        final FactHandle h = workingMemory.insert( cheddar );

        workingMemory.fireAllRules();

        // just one added
        assertEquals( "got cheese",
                      list.get( 0 ) );
        assertEquals( 1,
                      list.size() );

        workingMemory.retract( h );
        workingMemory.fireAllRules();

        // still just one
        assertEquals( 1,
                      list.size() );

        workingMemory.insert( new Cheese( "stilton",
                                          5 ) );
        workingMemory.fireAllRules();

        // now have one more
        assertEquals( 2,
View Full Code Here

Examples of org.drools.Cheese

        final RuleBase ruleBase = getRuleBase();
        ruleBase.addPackage( pkg );
        final WorkingMemory workingMemory = ruleBase.newStatefulSession();

        final Cheese stilton = new Cheese( "stinky",
                                           5 );
        workingMemory.insert( stilton );
        final QueryResults results = workingMemory.getQueryResults( "simple query" );
        assertEquals( 1,
                      results.size() );
View Full Code Here

Examples of org.drools.Cheese

        final List list = new ArrayList();
        workingMemory.setGlobal( "list",
                                 list );

        final Cheese stilton = new Cheese( "stilton",
                                           5 );
        workingMemory.insert( stilton );
        workingMemory.fireAllRules();

        assertEquals( stilton,
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        String outXml = execContent( "testInsertWithDefaults.in.1" );

        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        Cheese stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );

        FactHandle factHandle = (FactHandle) result.getFactHandle( "outStilton" );
        stilton = (Cheese) ksession.getObject( factHandle );
        assertEquals( 30,
                      stilton.getPrice() );

        String expectedXml = getContent( "testInsertWithDefaults.expected.1",
                                         ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );

        assertXMLEqual( expectedXml,
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        setExec( ksession );

        ExecutionResults result = execContent( "testGetObject.in.1",
                                               ExecutionResults.class );

        Cheese stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );

        String outXml = execContent( "testGetObject.in.2",
                                     ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
        result = unmarshalOutXml( outXml,
                                  ExecutionResults.class );

        stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );
    }
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        setExec( ksession );

        ExecutionResults result = execContent( "testRetractObject.in.1",
                                               ExecutionResults.class );

        Cheese stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );

        String outXml = execContent( "testRetractObject.in.2",
                                     ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );

        outXml = execContent( "testRetractObject.in.3",
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        String stiltonfh = ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm();

        Cheese stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );

        String expectedXml = getContent( "testModifyObject.expected.1",
                                         stiltonfh );

        assertXMLEqual( expectedXml,
                        outXml );

        execContent( "testModifyObject.in.2",
                     ExecutionResults.class,
                     stiltonfh );

        result = execContent( "testModifyObject.in.3",
                              ExecutionResults.class,
                              stiltonfh );

        stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 42,
                      stilton.getOldPrice() );
        assertEquals( 55,
                      stilton.getPrice() );

        //now test for code injection:
        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = false;

        execContent( "testModifyObject.in.4",
                     ExecutionResults.class,
                     stiltonfh );

        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = true;

        // should be the same as before
        result = execContent( "testModifyObject.in.5",
                              ExecutionResults.class,
                              stiltonfh );

        // The value gets turned into a literal to avoid injection
        stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( "throwException()",
                      stilton.getType() );

    }
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        ExecutionResults result = unmarshalOutXml( outXml,
                                                   ExecutionResults.class );

        List list = (List) result.getValue( "list1" );
        Cheese stilton25 = new Cheese( "stilton",
                                       30 );
        Cheese stilton30 = new Cheese( "stilton",
                                       35 );

        Set expectedList = new HashSet();
        expectedList.add( stilton25 );
        expectedList.add( stilton30 );
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

                                                   ExecutionResults.class );

        List list1 = (List) result.getValue( "list1" );
        assertEquals( 2,
                      list1.size() );
        assertTrue( list1.contains( new Cheese( "stilton",
                                                35 ) ) );
        assertTrue( list1.contains( new Cheese( "stilton",
                                                30 ) ) );

        List myFacts = (List) result.getValue( "myfacts" );
        assertEquals( 2,
                      list1.size() );
        assertTrue( myFacts.contains( new Cheese( "stilton",
                                                  35 ) ) );
        assertTrue( myFacts.contains( new Cheese( "stilton",
                                                  30 ) ) );

        List<FactHandle> factHandles = (List<FactHandle>) result.getFactHandle( "myfacts" );
        List list = new ArrayList();
        list.add( ksession.getObject( ((InternalFactHandle) factHandles.get( 0 )) ) );
        list.add( ksession.getObject( ((InternalFactHandle) factHandles.get( 1 )) ) );
        assertTrue( list.contains( new Cheese( "stilton",
                                               35 ) ) );
        assertTrue( list.contains( new Cheese( "stilton",
                                               30 ) ) );

        assertXMLEqual( getContent( "testInsertElementsWithReturnObjects.expected.1",
                                    factHandles.get( 0 ).toExternalForm(),
                                    factHandles.get( 1 ).toExternalForm() ),
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        assertXMLEqual( getContent( "testSetGlobal.expected.1",
                                    ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() ),
                        outXml );

        Cheese stilton = new Cheese( "stilton",
                                     30 );

        assertNull( result.getValue( "list1" ) );

        List list2 = (List) result.getValue( "list2" );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.