@Test public void testSetAndGetWithCommandRegisterWithEnds() { ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") // create two sessions, and assign names .getKieContainer(releaseId).newSession().set("s1").end() .getKieContainer(releaseId).newSession().set("s2").end() // initialise s1 with data .get("s1", KieSessionFluent.class) .insert("h1").fireAllRules().end() // initialise s2 with data .get("s2", KieSessionFluent.class) .insert("h2").fireAllRules().end() // assign s1 to out .get("s1", KieSessionFluent.class) .getGlobal("outS").out("outS1").dispose() .get("s2", KieSessionFluent.class) .getGlobal("outS").out("outS2").dispose(); RequestContext requestContext = ExecutableRunner.create().execute(f.getExecutable()); // Check that nothing went to the 'out' assertEquals("h1", requestContext.getOutputs().get("outS1")); assertEquals("h2", requestContext.getOutputs().get("outS2")); }
@Test public void testSetAndGetWithCommandRegisterWithoutEnds() { ExecutableBuilder f = ExecutableBuilder.create(); f.newApplicationContext("app1") // create two sessions, and assign names .getKieContainer(releaseId).newSession().set("s1").end() // this end is needed, it's the get(String, Class) we are checking to see if it auto ends .getKieContainer(releaseId).newSession().set("s2") // initialise s1 with data .get("s1", KieSessionFluent.class) .insert("h1").fireAllRules() // initialise s2 with data .get("s2", KieSessionFluent.class) .insert("h2").fireAllRules() // assign s1 to out .get("s1", KieSessionFluent.class) .getGlobal("outS").out("outS1").dispose() .get("s2", KieSessionFluent.class) .getGlobal("outS").out("outS2").dispose(); RequestContext requestContext = ExecutableRunner.create().execute(f.getExecutable()); // Check that nothing went to the 'out' assertEquals("h1", requestContext.getOutputs().get("outS1")); assertEquals("h2", requestContext.getOutputs().get("outS2")); }