use of org.kie.server.client.jms.BlockingResponseCallback in project droolsjbpm-integration by kiegroup.
the class DroolsJmsResponseHandlerIntegrationTest method testExecuteSimpleRuleFlowProcessWithAsyncResponseHandler.
@Test
public void testExecuteSimpleRuleFlowProcessWithAsyncResponseHandler() {
Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<Class<?>>(extraClasses.values()), configuration.getMarshallingFormat(), client.getClassLoader());
ResponseCallback responseCallback = new BlockingResponseCallback(marshaller);
ResponseHandler asyncResponseHandler = new AsyncResponseHandler(responseCallback);
ruleClient.setResponseHandler(asyncResponseHandler);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(commandsFactory.newSetGlobal(LIST_NAME, new ArrayList<String>(), LIST_OUTPUT_NAME));
commands.add(commandsFactory.newStartProcess(PROCESS_ID));
commands.add(commandsFactory.newGetGlobal(LIST_NAME, LIST_OUTPUT_NAME));
BatchExecutionCommand batchExecution = commandsFactory.newBatchExecution(commands, KIE_SESSION);
ServiceResponse<?> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, batchExecution);
assertThat(response).isNull();
ExecutionResults result = responseCallback.get(ExecutionResultImpl.class);
List<String> outcome = (List<String>) result.getValue(LIST_OUTPUT_NAME);
assertThat(outcome).isNotNull();
assertThat(outcome).containsExactly("Rule from first ruleflow group executed", "Rule from second ruleflow group executed");
}
use of org.kie.server.client.jms.BlockingResponseCallback in project droolsjbpm-integration by kiegroup.
the class JmsResponseHandlerIntegrationTest method testGetTasksUseOfAsyncResponseHandlerWithMarshaller.
@Test
public void testGetTasksUseOfAsyncResponseHandlerWithMarshaller() throws Exception {
ResponseCallback callback = new BlockingResponseCallback(createMarshaller());
testGetTaskResponseHandler(new AsyncResponseHandler(callback));
// now let's check if response has arrived
TaskSummaryList taskSummaryList = callback.get(TaskSummaryList.class);
assertThat(taskSummaryList).isNotNull();
assertThat(taskSummaryList.getItems()).isNotNull().hasSize(1);
}
use of org.kie.server.client.jms.BlockingResponseCallback in project droolsjbpm-integration by kiegroup.
the class JmsResponseHandlerIntegrationTest method testStartProcessUseOfAsyncResponseHandler.
@Test
public void testStartProcessUseOfAsyncResponseHandler() throws Exception {
ResponseCallback callback = new BlockingResponseCallback(null);
testStartProcessResponseHandler(new AsyncResponseHandler(callback));
// now let's check if response has arrived
ServiceResponsesList response = callback.get();
assertThat(response).isNotNull();
assertThat(response.getResponses()).isNotNull().hasSize(1);
KieServerAssert.assertSuccess(response.getResponses().get(0));
ServiceResponse<? extends Object> serviceResponse = response.getResponses().get(0);
Object result = serviceResponse.getResult();
assertThat(result).isNotNull();
}
use of org.kie.server.client.jms.BlockingResponseCallback in project droolsjbpm-integration by kiegroup.
the class JmsResponseHandlerIntegrationTest method testStartAndCompleteTaskUseOfAsyncResponseHandler.
@Test
public void testStartAndCompleteTaskUseOfAsyncResponseHandler() throws Exception {
ResponseCallback callback = new BlockingResponseCallback(null);
testStartAndCompleteTask(new AsyncResponseHandler(callback));
}
use of org.kie.server.client.jms.BlockingResponseCallback in project droolsjbpm-integration by kiegroup.
the class OptaPlannerJmsResponseHandlerIntegrationTest method testSolverWithAsyncResponseHandler.
@Test
public void testSolverWithAsyncResponseHandler() throws Exception {
Marshaller marshaller = MarshallerFactory.getMarshaller(new HashSet<>(extraClasses.values()), configuration.getMarshallingFormat(), client.getClassLoader());
ResponseCallback responseCallback = new BlockingResponseCallback(marshaller);
ResponseHandler asyncResponseHandler = new AsyncResponseHandler(responseCallback);
solverClient.setResponseHandler(asyncResponseHandler);
SolverInstance response = solverClient.createSolver(CONTAINER_1_ID, SOLVER_1_ID, SOLVER_1_CONFIG);
assertThat(response).isNull();
SolverInstance solver = responseCallback.get(SolverInstance.class);
assertThat(solver).isNotNull();
assertThat(solver.getContainerId()).isEqualTo(CONTAINER_1_ID);
assertThat(solver.getSolverId()).isEqualTo(SOLVER_1_ID);
List<SolverInstance> solverInstanceList = solverClient.getSolvers(CONTAINER_1_ID);
assertThat(solverInstanceList).isNull();
SolverInstanceList solverList = responseCallback.get(SolverInstanceList.class);
assertThat(solverList).isNotNull();
assertThat(solverList.getContainers()).isNotNull().isNotEmpty().hasSize(1);
solver = solverList.getContainers().get(0);
assertThat(solver.getSolverId()).isEqualTo(SOLVER_1_ID);
assertThat(solver.getStatus()).isEqualTo(SolverInstance.SolverStatus.NOT_SOLVING);
solverClient.solvePlanningProblem(CONTAINER_1_ID, SOLVER_1_ID, loadPlanningProblem(5, 15));
// Make sure the service call result is consumed
responseCallback.get(Void.class);
response = solverClient.getSolver(CONTAINER_1_ID, SOLVER_1_ID);
assertThat(response).isNull();
solver = responseCallback.get(SolverInstance.class);
assertThat(solver.getSolverId()).isEqualTo(SOLVER_1_ID);
assertThat(solver.getStatus()).isEqualTo(SolverInstance.SolverStatus.SOLVING);
solverClient.terminateSolverEarly(CONTAINER_1_ID, SOLVER_1_ID);
// Make sure the service call result is consumed
responseCallback.get(Void.class);
response = solverClient.getSolver(CONTAINER_1_ID, SOLVER_1_ID);
assertThat(response).isNull();
solver = responseCallback.get(SolverInstance.class);
assertThat(solver.getSolverId()).isEqualTo(SOLVER_1_ID);
assertThat(solver.getStatus()).isIn(SolverInstance.SolverStatus.TERMINATING_EARLY, SolverInstance.SolverStatus.NOT_SOLVING);
solverClient.disposeSolver(CONTAINER_1_ID, SOLVER_1_ID);
// Make sure the service call result is consumed
responseCallback.get(Void.class);
solverClient.getSolvers(CONTAINER_1_ID);
assertThat(response).isNull();
solverList = responseCallback.get(SolverInstanceList.class);
assertThat(solverList).isNotNull();
assertThat(solverList.getContainers()).isNullOrEmpty();
}
Aggregations