Package org.drools.runtime

Examples of org.drools.runtime.StatefulKnowledgeSession.fireAllRules()


       
        addDrlToKBase( kbase, "test_JBRULES_2206_2.drl" );
       
        // one rule was overridden and should activate
        verify( ael, times(3) ).activationCreated( any( ActivationCreatedEvent.class ) );
        fireCount = session.fireAllRules();
        // that rule should fire again
        assertEquals( 1, fireCount );

        session.dispose();
    }
View Full Code Here


            cheeseHandles[i] = (FactHandle) ksession.insert( cheese[i] );
        }
        final FactHandle bobHandle = (FactHandle) ksession.insert( bob );
       
        // ---------------- 1st scenario
        ksession.fireAllRules();
       
        ArgumentCaptor<AfterActivationFiredEvent> cap = ArgumentCaptor.forClass(AfterActivationFiredEvent.class);       
        Mockito.verify( ael ).afterActivationFired( cap.capture() );
       
        Activation activation = cap.getValue().getActivation();
View Full Code Here

        // ---------------- 2nd scenario
        final int index = 1;
        cheese[index].setPrice( 9 );
        ksession.update( cheeseHandles[index],
                   cheese[index] );
        ksession.fireAllRules();

        Mockito.verify( ael ).afterActivationFired( cap.capture() );
       
        activation = cap.getValue().getActivation();
        assertThat( ((Number)activation.getDeclarationValue( "$sum" )).intValue(), is( 24 ) );
View Full Code Here

        Mockito.reset( ael );
        // ---------------- 3rd scenario
        bob.setLikes( "brie" );
        ksession.update( bobHandle,
                   bob );
        ksession.fireAllRules();

        Mockito.verify( ael ).afterActivationFired( cap.capture() );
       
        activation = cap.getValue().getActivation();
        assertThat( ((Number)activation.getDeclarationValue( "$sum" )).intValue(), is( 32 ) );
View Full Code Here

        assertThat( ((Number)activation.getDeclarationValue( "$avg" )).intValue(), is( 16 ) );

        Mockito.reset( ael );
        // ---------------- 4th scenario
        ksession.retract( cheeseHandles[3] );
        ksession.fireAllRules();

        Mockito.verify( ael ).afterActivationFired( cap.capture() );
       
        activation = cap.getValue().getActivation();
        assertThat( ((Number)activation.getDeclarationValue( "$sum" )).intValue(), is( 17 ) );
View Full Code Here

        List list;

        ksession.insert( c1 );
        final FactHandle h = ksession.insert( c2 );
        ksession.insert( c3 );
        ksession.fireAllRules();

        // Check logical Insertions where made for c2 and c3       
        list = new ArrayList( ksession.getObjects( new ClassObjectFilter( Person.class ) ) );
        assertEquals( 2,
                      list.size() );
View Full Code Here

        }       
        Collection<KnowledgePackage> kpkgs2 = kbuilder.getKnowledgePackages();
        kbase.addKnowledgePackages( kpkgs2 );
        kbase = SerializationHelper.serializeObject( kbase );

        ksession.fireAllRules();

        kbase = ksession.getKnowledgeBase();

        // check all now have just one logical assertion each
        list = new ArrayList( ksession.getObjects( new ClassObjectFilter( Person.class ) ) );
View Full Code Here

        final Cheese provolone = new Cheese( "provolone",
                                             12 );
        final FactHandle provoloneHandle = session.insert( provolone );

        session.fireAllRules();

        assertEquals( 3,
                      list.size() );

        assertEquals( 3,
View Full Code Here

                                           1 );
        final Cheese cheese2 = new Cheese( cheese1.getType(),
                                           1 );

        final FactHandle h1 = session.insert( cheese1 );
        session.fireAllRules();
        Collection< ? > list = session.getObjects( new ClassObjectFilter( cheese1.getType().getClass() ) );
        assertEquals( 1,
                      list.size() );
        // probably dangerous, as contains works with equals, not identity
        assertEquals( cheese1.getType(),
View Full Code Here

        assertEquals( cheese1.getType(),
                      list.iterator().next() );
        // FactHandle ht = workingMemory.getFactHandle(c1.getType());

        final FactHandle h2 = session.insert( cheese2 );
        session.fireAllRules();
        list = session.getObjects( new ClassObjectFilter( cheese1.getType().getClass() ) );
        assertEquals( 1,
                      list.size() );
        assertEquals( cheese1.getType(),
                      list.iterator().next() );
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.