Search in sources :

Example 1 with ExecuteCommand

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());
}
Also used : KieBase(org.kie.api.KieBase) ExecutionResults(org.kie.api.runtime.ExecutionResults) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) ExecuteCommand(org.drools.core.command.ExecuteCommand) ArrayList(java.util.ArrayList) BatchExecutionCommand(org.kie.api.command.BatchExecutionCommand) KieSession(org.kie.api.runtime.KieSession) ArrayList(java.util.ArrayList) List(java.util.List) RequestContext(org.kie.api.runtime.RequestContext) ExecutableRunner(org.kie.api.runtime.ExecutableRunner) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecuteCommand (org.drools.core.command.ExecuteCommand)1 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)1 Test (org.junit.Test)1 KieBase (org.kie.api.KieBase)1 BatchExecutionCommand (org.kie.api.command.BatchExecutionCommand)1 ExecutableRunner (org.kie.api.runtime.ExecutableRunner)1 ExecutionResults (org.kie.api.runtime.ExecutionResults)1 KieSession (org.kie.api.runtime.KieSession)1 RequestContext (org.kie.api.runtime.RequestContext)1