use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcessesByContainerIdWrongId.
@Test
public void testFindProcessesByContainerIdWrongId() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("containerId", "wrong-container-id");
parameters.put("page", "0");
parameters.put("pageSize", "10");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessesByContainerId");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(List.class);
final List<ProcessDefinition> processDefinitions = (List<ProcessDefinition>) response;
Assertions.assertThat(processDefinitions).isEmpty();
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcessesByContainerId.
@Test
public void testFindProcessesByContainerId() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("containerId", CONTAINER_ID);
parameters.put("page", "0");
parameters.put("pageSize", "10");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessesByContainerId");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(List.class);
final List<ProcessDefinition> processDefinitions = (List<ProcessDefinition>) response;
Assertions.assertThat(processDefinitions).isNotEmpty();
final List<String> processIds = processDefinitions.stream().map(p -> p.getId()).collect(Collectors.toList());
Assertions.assertThat(processIds).contains(PROCESS_ID);
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessByContainerIdProcessId.
@Override
public ProcessDefinition findProcessByContainerIdProcessId(String containerId, String processId) {
ProcessDefinition result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_ID, processId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_DEFINITIONS_BY_CONTAINER_ID_DEF_ID_GET_URI, valuesMap), ProcessDefinition.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessesByDeploymentIdProcessId", new Object[] { containerId, processId })));
ServiceResponse<ProcessDefinition> response = (ServiceResponse<ProcessDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
return result;
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class KieServerTest method testProcessStartAndWorkOnUserTask.
@Test
public void testProcessStartAndWorkOnUserTask() {
// query for all available process definitions
QueryServicesClient queryClient = kieServicesClient.getServicesClient(QueryServicesClient.class);
List<ProcessDefinition> processes = queryClient.findProcesses(0, 10);
assertEquals(1, processes.size());
ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class);
// get details of process definition
ProcessDefinition definition = processClient.getProcessDefinition(containerId, processId);
assertNotNull(definition);
assertEquals(processId, definition.getId());
// start process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("employee", "john");
params.put("reason", "test on spring boot");
Long processInstanceId = processClient.startProcess(containerId, processId, params);
assertNotNull(processInstanceId);
UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class);
// find available tasks
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(user, 0, 10);
assertEquals(1, tasks.size());
// complete task
Long taskId = tasks.get(0).getId();
taskClient.startTask(containerId, taskId, user);
taskClient.completeTask(containerId, taskId, user, null);
// find active process instances
List<ProcessInstance> instances = queryClient.findProcessInstances(0, 10);
assertEquals(1, instances.size());
// at the end abort process instance
processClient.abortProcessInstance(containerId, processInstanceId);
ProcessInstance processInstance = queryClient.findProcessInstanceById(processInstanceId);
assertNotNull(processInstance);
assertEquals(3, processInstance.getState().intValue());
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class KeycloakKieServerTest method testProcessStartAndAbort.
@Test
public void testProcessStartAndAbort() {
setupClient(JOHN, JOHN_PW);
// query for all available process definitions
QueryServicesClient queryClient = kieServicesClient.getServicesClient(QueryServicesClient.class);
List<ProcessDefinition> processes = queryClient.findProcesses(0, 10);
assertEquals(2, processes.size());
ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class);
// get details of process definition
ProcessDefinition definition = processClient.getProcessDefinition(containerId, processId);
assertNotNull(definition);
assertEquals(processId, definition.getId());
// start process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("employee", "john");
params.put("reason", "test on spring boot");
Long processInstanceId = processClient.startProcess(containerId, processId, params);
assertNotNull(processInstanceId);
// find active process instances
List<ProcessInstance> instances = queryClient.findProcessInstances(0, 10);
assertEquals(1, instances.size());
// at the end abort process instance
processClient.abortProcessInstance(containerId, processInstanceId);
ProcessInstance processInstance = queryClient.findProcessInstanceById(processInstanceId);
assertNotNull(processInstance);
assertEquals(3, processInstance.getState().intValue());
}
Aggregations