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());
}
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");
}
};
}
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);
}
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());
}
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());
}
Aggregations