use of org.drools.core.command.ExecuteCommand in project drools by kiegroup.
the class ExecuteCommandDisconnectedTest method executeDisconnected.
@Test
public void executeDisconnected() {
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
ExecutionResultImpl localKresults = new ExecutionResultImpl();
RequestContext context = RequestContext.create().with(ksession);
ExecutableRunner runner = ExecutableRunner.create();
List cmds = new ArrayList();
cmds.add(new InsertObjectCommand(new String("Hi!"), "handle"));
BatchExecutionCommand batchCmd = CommandFactory.newBatchExecution(cmds, "kresults");
ExecuteCommand execCmd = new ExecuteCommand(batchCmd, true);
ExecutionResults results = execCmd.execute(context);
assertNotNull(results);
assertNotNull(results.getFactHandle("handle"));
assertTrue(((DefaultFactHandle) results.getFactHandle("handle")).isDisconnected());
cmds = new ArrayList();
cmds.add(new InsertObjectCommand(new String("Hi!"), "handle"));
batchCmd = CommandFactory.newBatchExecution(cmds, "kresults");
execCmd = new ExecuteCommand(batchCmd);
results = execCmd.execute(context);
assertNotNull(results);
assertNotNull(results.getFactHandle("handle"));
assertFalse(((DefaultFactHandle) results.getFactHandle("handle")).isDisconnected());
}
Aggregations