use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class KeycloakKieServerTest method testProcessStartAndWorkOnUserTask.
@Test
public void testProcessStartAndWorkOnUserTask() {
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);
UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class);
// find available tasks
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(JOHN, 0, 10);
assertEquals(1, tasks.size());
// complete task
Long taskId = tasks.get(0).getId();
taskClient.startTask(containerId, taskId, JOHN);
taskClient.completeTask(containerId, taskId, JOHN, null);
// find active process instances
List<ProcessInstance> instances = queryClient.findProcessInstances(0, 10);
assertEquals(1, instances.size());
tasks = taskClient.findTasksAssignedAsPotentialOwner(JOHN, 0, 10);
assertEquals(1, tasks.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 RuntimeDataServiceIntegrationTest method testGetProcessDefinitionByContainerAndId.
@Test
public void testGetProcessDefinitionByContainerAndId() throws Exception {
ProcessDefinition definition = queryClient.findProcessByContainerIdProcessId(CONTAINER_ID, PROCESS_ID_USERTASK);
assertNotNull(definition);
assertEquals(PROCESS_ID_USERTASK, definition.getId());
assertEquals("usertask", definition.getName());
assertEquals("1.0", definition.getVersion());
assertEquals("org.jbpm", definition.getPackageName());
assertEquals(CONTAINER_ID, definition.getContainerId());
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class ProcessDefinitionIntegrationTest method testTimerProcessDefinition.
@Test
public void testTimerProcessDefinition() {
ProcessDefinition result = processClient.getProcessDefinition(CONTAINER_ID, PROCESS_ID_TIMER);
assertNotNull(result);
assertEquals(PROCESS_ID_TIMER, result.getId());
assertEquals("Timer Process", result.getName());
assertEquals("com.sample", result.getPackageName());
assertEquals("1", result.getVersion());
assertEquals(CONTAINER_ID, result.getContainerId());
assertNotNull(result.getNodes());
assertEquals(3, result.getNodes().size());
assertNotNull(result.getTimers());
assertEquals(1, result.getTimers().size());
TimerDefinition timer = result.getTimers().iterator().next();
assertEquals(0, timer.getId().longValue());
assertEquals(2l, timer.getNodeId().longValue());
assertEquals("timer", timer.getNodeName());
assertEquals("_2", timer.getUniqueId());
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class ProcessDefinitionIntegrationTest method testEvaluationProcessDefinition.
@Test
public void testEvaluationProcessDefinition() {
ProcessDefinition result = processClient.getProcessDefinition(CONTAINER_ID, PROCESS_ID_EVALUATION);
assertNotNull(result);
assertEquals(PROCESS_ID_EVALUATION, result.getId());
assertEquals("evaluation", result.getName());
assertEquals("org.jbpm", result.getPackageName());
assertEquals("1.0", result.getVersion());
assertEquals(CONTAINER_ID, result.getContainerId());
// assert variable definitions
Map<String, String> variables = result.getProcessVariables();
assertNotNull(variables);
assertEquals(3, variables.size());
assertTrue(variables.containsKey("name"));
assertTrue(variables.containsKey("item"));
assertTrue(variables.containsKey("outcome"));
assertEquals("String", variables.get("name"));
assertEquals("java.util.List", variables.get("item"));
assertEquals("Boolean", variables.get("outcome"));
// assert associated entities - users and groups
Map<String, String[]> entities = result.getAssociatedEntities();
assertNotNull(entities);
assertTrue(entities.containsKey("Evaluate items?"));
String[] evaluateItemsEntities = entities.get("Evaluate items?");
assertEquals(2, evaluateItemsEntities.length);
assertEquals(USER_YODA, evaluateItemsEntities[0]);
assertEquals("HR,PM", evaluateItemsEntities[1]);
// assert reusable subprocesses
assertEquals(0, result.getReusableSubProcesses().size());
// assert services tasks
assertEquals(1, result.getServiceTasks().size());
assertTrue(result.getServiceTasks().containsKey("Email results"));
// assert type of the services task for 'Email results' name
assertEquals("Email", result.getServiceTasks().get("Email results"));
assertNotNull(result.getNodes());
assertEquals(4, result.getNodes().size());
assertNotNull(result.getTimers());
assertTrue(result.getTimers().isEmpty());
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcesses.
@Test
public void testFindProcesses() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("page", "0");
parameters.put("pageSize", "10");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcesses");
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);
}
Aggregations