Package org.kie.api.runtime

Examples of org.kie.api.runtime.KieSession.retract()


        FactHandle handle = ksession.insert("go1");
        ksession.fireAllRules();
        System.out.println( "***** " + list + " *****");
        assertEquals( Arrays.asList(0L, 1L, 1L), list );
        list.clear();
        ksession.retract( handle );

        clock.advanceTime( 2550, TimeUnit.MILLISECONDS );

        handle = ksession.insert( "go2" );
        ksession.fireAllRules();
View Full Code Here


        handle = ksession.insert( "go2" );
        ksession.fireAllRules();
        System.out.println( "***** " + list + " *****");
        assertEquals( Arrays.asList( 0L, 0L, 1L ), list );
        list.clear();
        ksession.retract( handle );

        clock.advanceTime( 500, TimeUnit.MILLISECONDS );

        handle = ksession.insert( "go3" );
        ksession.fireAllRules();
View Full Code Here

        handle = ksession.insert( "go3" );
        ksession.fireAllRules();
        System.out.println( "***** " + list + " *****");
        assertEquals( Arrays.asList( 0L, 0L, 0L ), list );
        list.clear();
        ksession.retract( handle );

        ksession.dispose();
    }

    @Test
View Full Code Here

        FactHandle handle = (FactHandle) ksession.insert( "halt" );
        Thread.sleep( 2000 );

        // now check that rule "halt" fired once, creating one Integer
        assertEquals( 2, ksession.getFactCount() );
        ksession.retract( handle );
    }

    @Test(timeout=10000)
    public void testTimerRemoval() {
        try {
View Full Code Here

        assertEquals( java.util.Arrays.asList( 0, 0 ), list );

        ksession.insert( "halt" );

        Thread.sleep( 200 );
        ksession.retract( handle );
        assertEquals( 2, list.size() ); // halted, no more rule firing

        new Thread( new Runnable(){
            public void run(){ ksession.fireUntilHalt(); }
        } ).start();
View Full Code Here

                      l.size() );
        assertEquals( 2,
                      ((CheeseEqual) l.iterator().next()).getPrice() );

        h = getFactHandle( h, ksession );
        ksession.retract( h );
        ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, false);
        assertEquals( 0,
                      ksession.getObjects().size() );

        TruthMaintenanceSystem tms =  ((NamedEntryPoint)ksession.getEntryPoint(EntryPointId.DEFAULT.getEntryPointId()) ).getTruthMaintenanceSystem();
View Full Code Here

        assertEquals("agenda should be empty.",
                     0,
                     ((InternalAgenda)((StatefulKnowledgeSessionImpl) ksession).getAgenda()).agendaSize());

        h = getFactHandle( h, ksession );
        ksession.retract( h );
        ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, true);
        ksession.fireAllRules();
        ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, true);
        list = ksession.getObjects();
        assertEquals( "i was not asserted by not a => i.",
View Full Code Here

                      l.size() );
        assertEquals( 3,
                      ((CheeseEqual) l.iterator().next()).getPrice() );

        h = getFactHandle( h, ksession );
        ksession.retract( h );
        ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, true);


        Collection list = ksession.getObjects();
        // CheeseEqual was updated, making it stated, so it wouldn't have been logically deleted
View Full Code Here

        // CheeseEqual was updated, making it stated, so it wouldn't have been logically deleted
        assertEquals( 1,
                      list.size() );
        assertEquals( new CheeseEqual("person", 3), list.iterator().next());
        FactHandle fh = ksession.getFactHandle( list.iterator().next() );
        ksession.retract( fh );
       
        list = ksession.getObjects();
        assertEquals( 0,
                      list.size() );       
       
View Full Code Here

                ksession.insert(sprinkler1);
                ksession.fireAllRules();
                assertEquals(2, events.size());

                // phase 3
                ksession.retract(fireFact1);
                ksession.fireAllRules();
            } catch (Exception e) {
                System.err.println("Exception in thread " + Thread.currentThread().getName() + ": " + e.getLocalizedMessage());
                throw e;
            }
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.