Search in sources :

Example 6 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class ProcessDefinitionIntegrationTest method testCallEvaluationProcessDefinition.

@Test
public void testCallEvaluationProcessDefinition() {
    ProcessDefinition result = processClient.getProcessDefinition(CONTAINER_ID, PROCESS_ID_CALL_EVALUATION);
    assertNotNull(result);
    assertEquals(PROCESS_ID_CALL_EVALUATION, result.getId());
    assertEquals("call-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(1, variables.size());
    assertTrue(variables.containsKey("items"));
    assertEquals("java.util.List", variables.get("items"));
    // assert associated entities - users and groups
    Map<String, String[]> entities = result.getAssociatedEntities();
    assertNotNull(entities);
    assertTrue(entities.containsKey("Prepare"));
    String[] evaluateItemsEntities = entities.get("Prepare");
    assertEquals(1, evaluateItemsEntities.length);
    assertEquals(USER_YODA, evaluateItemsEntities[0]);
    // assert reusable subprocesses
    assertEquals(1, result.getReusableSubProcesses().size());
    assertEquals("definition-project.evaluation", result.getReusableSubProcesses().iterator().next());
    // assert services tasks
    assertEquals(0, result.getServiceTasks().size());
    assertNotNull(result.getNodes());
    assertEquals(5, 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 7 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieClientServicesIntegrationTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    KieServerInfo info = new KieServerInfo("mock", "1.2.3");
    List<String> capabilities = Arrays.asList(KieServerConstants.CAPABILITY_BPM, KieServerConstants.CAPABILITY_BPM_UI, KieServerConstants.CAPABILITY_BRM, KieServerConstants.CAPABILITY_BRP, KieServerConstants.CAPABILITY_CASE, KieServerConstants.CAPABILITY_DMN);
    info.setCapabilities(capabilities);
    ServiceResponse<KieServerInfo> response = new ServiceResponse<KieServerInfo>(ResponseType.SUCCESS, "Kie Server info");
    response.setResult(info);
    stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(response, KieServerInfo.class, ServiceResponse.class))));
    // case mock response
    ProcessDefinitionList caseResponse = new ProcessDefinitionList();
    caseResponse.setProcesses(new ProcessDefinition[] { new ProcessDefinition() });
    stubFor(get(urlMatching("/queries/cases/processes.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(caseResponse, ProcessDefinitionList.class, ProcessDefinition.class))));
    // document mock response
    DocumentInstance documentResponse = new DocumentInstance();
    documentResponse.setIdentifier("1234");
    stubFor(get(urlMatching("/documents/1234")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(documentResponse, DocumentInstance.class))));
    // job service mock response
    RequestInfoInstanceList jobResponse = new RequestInfoInstanceList();
    stubFor(get(urlMatching("/jobs.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(jobResponse, RequestInfoInstanceList.class))));
    // query service mock response
    NodeInstanceList queryResponse = new NodeInstanceList();
    stubFor(get(urlMatching("/queries/processes/instances/100/nodes/instances.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(queryResponse, NodeInstanceList.class))));
    // solver service mock response
    SolverInstanceList solverResponse = new SolverInstanceList();
    stubFor(get(urlMatching("/containers/my-container/solvers")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(solverResponse, SolverInstanceList.class))));
    // ui service mock response
    stubFor(get(urlMatching("/containers/my-container/forms/processes/my-process.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody("my form")));
    // user task mock response
    TaskSummaryList userTaskResponse = new TaskSummaryList();
    stubFor(get(urlMatching("/queries/tasks/instances.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(userTaskResponse, TaskSummaryList.class))));
    return new RouteBuilder() {

        @Override
        public void configure() {
            from("direct:start").to("kie:" + getAuthenticadUrl("admin", "admin")).to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) RequestInfoInstanceList(org.kie.server.api.model.instance.RequestInfoInstanceList) KieServerInfo(org.kie.server.api.model.KieServerInfo) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) SolverInstanceList(org.kie.server.api.model.instance.SolverInstanceList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) ServiceResponse(org.kie.server.api.model.ServiceResponse) DocumentInstance(org.kie.server.api.model.instance.DocumentInstance)

Example 8 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieClientServicesIntegrationTest method testCaseServiceCamelProducer.

@Test
public void testCaseServiceCamelProducer() throws Exception {
    MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
    mockEndpoint.expectedMessageCount(1);
    Map<String, Object> headers = new HashMap<>();
    headers.put(KIE_CLIENT, "case");
    headers.put(KIE_OPERATION, "findProcesses");
    headers.put(asCamelKieName("page"), 1);
    headers.put(asCamelKieName("pageSize"), 1);
    template.sendBodyAndHeaders("direct:start", null, headers);
    assertMockEndpointsSatisfied();
    List<ProcessDefinition> result = (List<ProcessDefinition>) getResultMessage(mockEndpoint.getExchanges().get(0)).getBody(List.class);
    assertCollectionSize(result, 1);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) HashMap(java.util.HashMap) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) List(java.util.List) SolverInstanceList(org.kie.server.api.model.instance.SolverInstanceList) RequestInfoInstanceList(org.kie.server.api.model.instance.RequestInfoInstanceList) Test(org.junit.Test)

Example 9 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieServerTest method testProcessStartAndAbortUsingAlias.

@Test
public void testProcessStartAndAbortUsingAlias() {
    // 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());
    String resolvedContainerId = aliasResolver.latest(containerAlias);
    // 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(resolvedContainerId, processId, params);
    assertNotNull(processInstanceId);
    resolvedContainerId = aliasResolver.forProcessInstance(containerAlias, processInstanceId);
    // find active process instances
    List<ProcessInstance> instances = queryClient.findProcessInstances(0, 10);
    assertEquals(1, instances.size());
    // at the end abort process instance
    processClient.abortProcessInstance(resolvedContainerId, 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) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) ProcessServicesClient(org.kie.server.client.ProcessServicesClient) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 10 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieServerTest method testProcessStartAndAbort.

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