use of org.drools.core.command.RequestContextImpl in project drools by kiegroup.
the class BatchRunFluentTest method testConversationScope.
@Test
public void testConversationScope() {
ExecutableRunner<RequestContext> runner = ExecutableRunner.create();
ExecutableBuilder f = ExecutableBuilder.create();
f.newApplicationContext("app1").startConversation().getKieContainer(releaseId).newSession().insert("h1").fireAllRules().getGlobal("outS").set("outS1", Scope.CONVERSATION).dispose();
RequestContextImpl requestContext = (RequestContextImpl) runner.execute(f.getExecutable());
// check that nothing went to the 'out'
assertEquals(null, requestContext.get("outS"));
String conversationId = requestContext.getConversationContext().getName();
assertEquals("h1", requestContext.getConversationContext().get("outS1"));
// Make another request, add to conversation context, assert old and new values are there.
f = new ExecutableBuilderImpl();
f.getApplicationContext("app1").joinConversation(conversationId).getKieContainer(releaseId).newSession().insert("h2").fireAllRules().getGlobal("outS").set("outS2", Scope.CONVERSATION).dispose();
requestContext = (RequestContextImpl) runner.execute(f.getExecutable());
assertEquals("h1", requestContext.getConversationContext().get("outS1"));
assertEquals("h2", requestContext.getConversationContext().get("outS2"));
// End the conversation, check it's now null
f = new ExecutableBuilderImpl();
f.endConversation(conversationId);
requestContext = (RequestContextImpl) runner.execute(f.getExecutable());
assertNull(requestContext.getConversationContext());
}
Aggregations