InfinispanSignalManagerFactory.class.getName() );
properties.setProperty( "drools.timerService",
JpaJDKTimerService.class.getName() );
SessionConfiguration config = new SessionConfiguration( properties );
SingleSessionCommandService service = createSingleSessionCommandService( kbase,
config,
env );
int sessionId = service.getSessionId();
registerWorkItemHandlers(service);
StartProcessCommand startProcessCommand = new StartProcessCommand();
startProcessCommand.setProcessId( "org.drools.test.TestProcess" );
ProcessInstance processInstance = service.execute( startProcessCommand );
System.out.println( "Started process instance " + processInstance.getId() );
TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
WorkItem workItem = handler.getWorkItem();
assertNotNull( workItem );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand();
getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() );
processInstance = service.execute( getProcessInstanceCommand );
assertNotNull( processInstance );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
CompleteWorkItemCommand completeWorkItemCommand = new CompleteWorkItemCommand();
completeWorkItemCommand.setWorkItemId( workItem.getId() );
service.execute( completeWorkItemCommand );
workItem = handler.getWorkItem();
assertNotNull( workItem );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
getProcessInstanceCommand = new GetProcessInstanceCommand();
getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() );
processInstance = service.execute( getProcessInstanceCommand );
assertNotNull( processInstance );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
completeWorkItemCommand = new CompleteWorkItemCommand();
completeWorkItemCommand.setWorkItemId( workItem.getId() );
service.execute( completeWorkItemCommand );
workItem = handler.getWorkItem();
assertNotNull( workItem );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
getProcessInstanceCommand = new GetProcessInstanceCommand();
getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() );
processInstance = service.execute( getProcessInstanceCommand );
assertNotNull( processInstance );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
completeWorkItemCommand = new CompleteWorkItemCommand();
completeWorkItemCommand.setWorkItemId( workItem.getId() );
service.execute( completeWorkItemCommand );
workItem = handler.getWorkItem();
assertNull( workItem );
service.dispose();
service = createSingleSessionCommandService( sessionId,
kbase,
config,
env );
registerWorkItemHandlers(service);
getProcessInstanceCommand = new GetProcessInstanceCommand();
getProcessInstanceCommand.setProcessInstanceId( processInstance.getId() );
processInstance = service.execute( getProcessInstanceCommand );
assertNull( processInstance );
service.dispose();
}