Examples of FluentStandardSimulationImpl


Examples of org.drools.fluent.standard.imp.FluentStandardSimulationImpl

public class StandardFluentTest {

    @Test
    public void testUsingImplicit() {
        FluentStandardSimulation f = new FluentStandardSimulationImpl();       
       
        VariableContext<Person> pc = f.<Person> getVariableContext();

        List<String> imports = new ArrayList<String>();
        imports.add( "org.hamcrest.MatcherAssert.assertThat" );
        imports.add( "org.hamcrest.CoreMatchers.is" );
        imports.add( "org.hamcrest.CoreMatchers.equalTo" );
        imports.add( "org.hamcrest.CoreMatchers.allOf" );

        ReflectiveMatcherFactory rf = new ReflectiveMatcherFactory( imports );

        String str = "package org.drools.simulation.test\n" +
                     "import " + Person.class.getName() + "\n" +
                     "global java.util.List list\n" +
                     "rule setTime when then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n end\n " +
                     "rule updateAge no-loop when  $p : Person() then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n modify( $p ) { setAge( $p.getAge() + 10 ) }; end\n";       
       
        List list = new ArrayList();
       
        VariableContext<?> vc = f.getVariableContext();
        // @formatter:off         
            f.newPath("init")
                 .newStep( 0 )
                     .newKnowledgeBuilder()
                         .add( ResourceFactory.newByteArrayResource( str.getBytes() ),
                               ResourceType.DRL )
                     .end(ContextManager.ROOT, KnowledgeBuilder.class.getName() )
View Full Code Here

Examples of org.drools.fluent.standard.imp.FluentStandardSimulationImpl

           
    }
   
    @Test
    public void testUsingExplicit() {
        FluentStandardSimulation f = new FluentStandardSimulationImpl();       
       
        VariableContext<Person> pc = f.<Person> getVariableContext();

        List<String> imports = new ArrayList<String>();
        imports.add( "org.hamcrest.MatcherAssert.assertThat" );
        imports.add( "org.hamcrest.CoreMatchers.is" );
        imports.add( "org.hamcrest.CoreMatchers.equalTo" );
        imports.add( "org.hamcrest.CoreMatchers.allOf" );

        ReflectiveMatcherFactory rf = new ReflectiveMatcherFactory( imports );

        String str1 = "package org.drools.simulation.test\n" +
                     "import " + Person.class.getName() + "\n" +
                     "global java.util.List list\n" +
                     "rule setTime when then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n end\n " +
                     "rule updateAge no-loop when  $p : Person() then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n modify( $p ) { setAge( $p.getAge() + 20 ) }; end\n";       

        String str2 = "package org.drools.simulation.test\n" +
                "import " + Person.class.getName() + "\n" +
                "global java.util.List list\n" +
                "rule setTime when then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n end\n " +
                "rule updateAge no-loop when  $p : Person() then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n modify( $p ) { setAge( $p.getAge() + 10 ) }; end\n";       
       
        List list1 = new ArrayList();
        List list2 = new ArrayList();
       
        VariableContext<?> vc = f.getVariableContext();
        // @formatter:off         
            f.newPath("init")
                 .newStep( 0 )
                     .newKnowledgeBuilder()
                         .add( ResourceFactory.newByteArrayResource( str1.getBytes() ),
                               ResourceType.DRL )
                     .end(ContextManager.ROOT, KnowledgeBuilder.class.getName() )
View Full Code Here

Examples of org.drools.fluent.standard.imp.FluentStandardSimulationImpl

    }   
   
   
    @Test
    public void testUsingDifferentPosAsserts() {
        FluentStandardSimulation f = new FluentStandardSimulationImpl();       
       
        VariableContext<Person> pc = f.<Person> getVariableContext();

        List<String> imports = new ArrayList<String>();
        imports.add( "org.hamcrest.MatcherAssert.assertThat" );
        imports.add( "org.hamcrest.CoreMatchers.is" );
        imports.add( "org.hamcrest.CoreMatchers.equalTo" );
        imports.add( "org.hamcrest.CoreMatchers.allOf" );

        ReflectiveMatcherFactory rf = new ReflectiveMatcherFactory( imports );

        String str = "package org.drools.simulation.test\n" +
                     "import " + Person.class.getName() + "\n" +
                     "global java.util.List list\n" +
                     "rule setTime when then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n end\n " +
                     "rule updateAge no-loop when  $p : Person() then list.add( kcontext.getKnowledgeRuntime().getSessionClock().getCurrentTime() );\n modify( $p ) { setAge( $p.getAge() + 10 ) }; end\n";       
       
        List list = new ArrayList();
       
        VariableContext<?> vc = f.getVariableContext();
        // @formatter:off         
            f.newPath("init")
                 .newStep( 0 )
                     .newKnowledgeBuilder()
                         .add( ResourceFactory.newByteArrayResource( str.getBytes() ),
                               ResourceType.DRL )
                     .end(ContextManager.ROOT, KnowledgeBuilder.class.getName() )
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.