use of org.kie.api.runtime.RequestContext in project drools by kiegroup.
the class BatchRunFluentTest method testApplicationScope.
@Test
public void testApplicationScope() {
ExecutableRunner<RequestContext> runner = ExecutableRunner.create();
ExecutableBuilder f = ExecutableBuilder.create();
f.newApplicationContext("app1").getKieContainer(releaseId).newSession().insert("h1").fireAllRules().getGlobal("outS").set("outS1", Scope.APPLICATION).dispose();
RequestContext requestContext = runner.execute(f.getExecutable());
// Check that nothing went to the 'out'
assertEquals(null, requestContext.get("outS"));
assertEquals("h1", requestContext.getApplicationContext().get("outS1"));
// Make another request, add to application context, assert old and new values are there.
f = new ExecutableBuilderImpl();
f.getApplicationContext("app1").getKieContainer(releaseId).newSession().insert("h2").fireAllRules().getGlobal("outS").set("outS2", Scope.APPLICATION).dispose();
requestContext = (RequestContextImpl) runner.execute(f.getExecutable());
assertEquals("h1", requestContext.getApplicationContext().get("outS1"));
assertEquals("h2", requestContext.getApplicationContext().get("outS2"));
}
use of org.kie.api.runtime.RequestContext in project drools by kiegroup.
the class BatchRunFluentTest method testOutWithoutPriorSetAndNoName.
@Test
public void testOutWithoutPriorSetAndNoName() {
ExecutableBuilder f = ExecutableBuilder.create();
f.newApplicationContext("app1").getKieContainer(releaseId).newSession().insert("h1").fireAllRules().getGlobal("outS").out().dispose();
try {
RequestContext requestContext = ExecutableRunner.create().execute(f.getExecutable());
assertEquals("h1", requestContext.get("out1"));
fail("Must throw Exception, as no prior set was called and no name given to out");
} catch (Exception e) {
}
}
use of org.kie.api.runtime.RequestContext in project drools by kiegroup.
the class BatchRunFluentTest method testOutName.
@Test
public void testOutName() {
ExecutableBuilder f = ExecutableBuilder.create();
f.newApplicationContext("app1").getKieContainer(releaseId).newSession().insert("h1").fireAllRules().getGlobal("outS").out("outS").dispose();
RequestContext requestContext = ExecutableRunner.create().execute(f.getExecutable());
assertEquals("h1", requestContext.get("outS"));
}
use of org.kie.api.runtime.RequestContext in project drools by kiegroup.
the class BatchRunFluentTest method testSetAndGetWithCommandRegisterWithoutEnds.
@Test
public void testSetAndGetWithCommandRegisterWithoutEnds() {
ExecutableBuilder f = ExecutableBuilder.create();
f.newApplicationContext("app1").getKieContainer(releaseId).newSession().set("s1").end().getKieContainer(releaseId).newSession().set("s2").get("s1", KieSessionFluent.class).insert("h1").fireAllRules().get("s2", KieSessionFluent.class).insert("h2").fireAllRules().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.get("outS1"));
assertEquals("h2", requestContext.get("outS2"));
}
Aggregations