Search in sources :

Example 11 with ProcessDefinition

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());
}
Also used : QueryServicesClient(org.kie.server.client.QueryServicesClient) HashMap(java.util.HashMap) UserTaskServicesClient(org.kie.server.client.UserTaskServicesClient) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) ProcessServicesClient(org.kie.server.client.ProcessServicesClient) TaskSummary(org.kie.server.api.model.instance.TaskSummary) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 12 with ProcessDefinition

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());
}
Also used : ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) Test(org.junit.Test)

Example 13 with ProcessDefinition

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());
}
Also used : TimerDefinition(org.kie.server.api.model.definition.TimerDefinition) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) Test(org.junit.Test)

Example 14 with ProcessDefinition

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());
}
Also used : ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) Test(org.junit.Test)

Example 15 with ProcessDefinition

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);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) QueryDefinition(org.kie.server.api.model.definition.QueryDefinition) ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) HashMap(java.util.HashMap) Test(org.junit.Test) Collectors(java.util.stream.Collectors) HashMap(java.util.HashMap) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) List(java.util.List) ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand) Test(org.junit.Test)

Aggregations

ProcessDefinition (org.kie.server.api.model.definition.ProcessDefinition)24 Test (org.junit.Test)19 HashMap (java.util.HashMap)16 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)10 QueryServicesClient (org.kie.server.client.QueryServicesClient)8 List (java.util.List)6 ExecutionServerCommand (org.kie.camel.container.api.ExecutionServerCommand)6 ProcessServicesClient (org.kie.server.client.ProcessServicesClient)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Collectors (java.util.stream.Collectors)4 Arrays (java.util.Arrays)3 Map (java.util.Map)3 Assertions (org.assertj.core.api.Assertions)3 ServiceResponse (org.kie.server.api.model.ServiceResponse)3 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)3 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)2 ArrayList (java.util.ArrayList)2 CommandScript (org.kie.server.api.commands.CommandScript)2 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)2 KieServerCommand (org.kie.server.api.model.KieServerCommand)2