Examples of Cheese


Examples of org.drools.camel.testdomain.Cheese

                                              inXml,
                                              String.class );
        ExecutionResults result = template.requestBody( "direct:unmarshal",
                                                        outXml,
                                                        ExecutionResults.class );
        Cheese stilton = (Cheese) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );

        FactHandle factHandle = ((FactHandle) result.getFactHandle( "outStilton" ));

        String expectedXml = "";
        expectedXml += "<execution-results>\n";
        expectedXml += "  <result identifier=\"outStilton\">\n";
        expectedXml += "    <org.drools.camel.testdomain.Cheese>\n";
        expectedXml += "      <type>stilton</type>\n";
        expectedXml += "      <oldPrice>0</oldPrice>\n";
        expectedXml += "      <price>30</price>\n";
        expectedXml += "    </org.drools.camel.testdomain.Cheese>\n";
        expectedXml += "  </result>\n";
        expectedXml += "  <fact-handle identifier=\"outStilton\" external-form=\"" + factHandle.toExternalForm() + "\" /> \n";
        expectedXml += "</execution-results>\n";

        assertXMLEqual( expectedXml,
                        outXml );

        inXml = "";
        inXml += "<batch-execution>";
        inXml += "  <modify fact-handle='" + factHandle.toExternalForm() + "'> <set accessor='oldPrice' value='42' /><set accessor='price' value='50' /></modify>";
        inXml += "  <fire-all-rules />";
        inXml += "</batch-execution>";
        template.requestBody( "direct:exec",
                              inXml,
                              String.class );

        inXml = "";
        inXml += "<batch-execution>";
        inXml += "  <get-object out-identifier='outCheddar' fact-handle='" + factHandle.toExternalForm() + "' />";
        inXml += "</batch-execution>";
        setExec( ksession );

        outXml = template.requestBody( "direct:exec",
                                       inXml,
                                       String.class );
        result = template.requestBody( "direct:unmarshal",
                                       outXml,
                                       ExecutionResults.class );

        Cheese cheddar = (Cheese) result.getValue( "outCheddar" );
        assertEquals( 42,
                      cheddar.getOldPrice() );
        assertEquals( 55,
                      cheddar.getPrice() );

        //now test for code injection:
        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = false;
        inXml = "";
        inXml += "<batch-execution>";
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        ExecutionResults result = template.requestBody( "direct:unmarshal",
                                                        outXml,
                                                        ExecutionResults.class );

        List list = (List) result.getValue( "list" );
        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

                        outXml );

        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );

        List list = (List) result.getValue( "list" );
        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

        assertXMLEqual( expectedXml,
                        outXml );

        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );
        Cheese stilton = new Cheese( "stilton",
                                     30 );

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

        List list2 = (List) result.getValue( "list2" );
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        assertXMLEqual( expectedXml,
                outXml );

        ExecutionResults batchResult = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );

        Cheese stilton1 = new Cheese( "stilton",
                1 );
        Cheese cheddar1 = new Cheese( "cheddar",
                1 );
        Cheese stilton2 = new Cheese( "stilton",
                2 );
        Cheese cheddar2 = new Cheese( "cheddar",
                2 );

        Set set = new HashSet();
        List list = new ArrayList();
        list.add( stilton1 );
View Full Code Here

Examples of org.drools.camel.testdomain.Cheese

        assertXMLEqual( expectedXml,
                        outXml );

        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );
        List list = (List) result.getValue( "list" );
        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 result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );

        // brie should not have been added to the list
        List list = (List) result.getValue( "list" );
        Cheese stilton25 = new Cheese( "stilton",
                                       30 );
        Cheese stilton30 = new Cheese( "stilton",
                                       35 );

        Set expectedList = new HashSet();
        expectedList.add( stilton25 );
        expectedList.add( stilton30 );

        assertEquals( expectedList,
                      new HashSet( list ) );

        // brie should not have changed
        Cheese brie10 = new Cheese( "brie",
                                    10 );
        brie10.setOldPrice( 5 );
        assertEquals( brie10,
                      result.getValue( "outBrie" ) );
    }
View Full Code Here

Examples of org.drools.compiler.Cheese

        Person p = new Person( "x" );
        p.addAddress( new Address( "x", "x", "x" ) );
        p.addAddress( new Address( "y", "y", "y" ) );
        ksession.insert( p );

        ksession.insert( new Cheese( "x" ) );
        assertEquals( 1, ksession.fireAllRules() );
        ksession.dispose();
    }
View Full Code Here

Examples of org.drools.core.test.model.Cheese

                                                   buildContext ); // no memory

        final MockObjectSink sink = new MockObjectSink();
        alphaNode.addObjectSink( sink );

        final Cheese cheddar = new Cheese( "cheddar",
                                           5 );
        final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.insert( cheddar );

        // check sink is empty
        assertLength( 0,
                      sink.getAsserted() );

        // check alpha memory is empty
        final AlphaMemory memory = (AlphaMemory) workingMemory.getNodeMemory( alphaNode );

        // object should assert as it passes text
        alphaNode.assertObject( f0,
                                context,
                                workingMemory );

        assertEquals( 1,
                      sink.getAsserted().size() );

        Object[] list = (Object[]) sink.getAsserted().get( 0 );
        assertSame( cheddar,
                    workingMemory.getObject( (DefaultFactHandle) list[0] ) );

        final Cheese stilton = new Cheese( "stilton",
                                           6 );
        final DefaultFactHandle f1 = new DefaultFactHandle( 1,
                                                            stilton );

        // object should NOT assert as it does not pass test
View Full Code Here

Examples of org.drools.decisiontable.Cheese

        StatelessKieSession ksession = (StatelessKieSession) context.getBean("ksession-table-1");

        assertNotNull(ksession);

        // Cheeses selection
        Cheese cheese = new Cheese();
        cheese.setPrice(250);
        cheese.setType("cheddar");

        // Young person
        Person person = new Person();
        person.setName("Young Scott");
        person.setAge(21);

        List cmds = new ArrayList();
        cmds.add( CommandFactory.newSetGlobal("list", new ArrayList(), true) );
        cmds.add( CommandFactory.newInsert(person,"yscott"));
        cmds.add( CommandFactory.newInsert(cheese,"cheddar"));
        cmds.add( CommandFactory.newFireAllRules());

        // Execute the list
        ExecutionResults results = ksession.execute(CommandFactory.newBatchExecution(cmds));
        List list = (List) results.getValue("list");
        assertEquals(1, list.size());
        assertTrue(list.contains("Young man cheddar"));

        // Old person
        person = new Person();
        person.setName("Old Scott");
        person.setAge(42);

        cheese = new Cheese();
        cheese.setPrice(150);
        cheese.setType("stilton");

        cmds = new ArrayList();
        cmds.add( CommandFactory.newSetGlobal("list", new ArrayList(), true) );
        cmds.add( CommandFactory.newInsert(person,"oscott"));
        cmds.add( CommandFactory.newInsert(cheese,"stilton"));
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.