use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartAndSignalProcess.
@Test
public void testStartAndSignalProcess() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "signal");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Collection<String> signals = processService.getAvailableSignals(processInstanceId);
assertNotNull(signals);
assertEquals(1, signals.size());
assertTrue(signals.contains("MySignal"));
processService.signalProcessInstance(processInstanceId, "MySignal", null);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartProcessAndCompleteWorkItem.
@Test
public void testStartProcessAndCompleteWorkItem() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
assertEquals("Write a Document", activeNodes.iterator().next().getName());
Map<String, Object> outcome = new HashMap<String, Object>();
outcome.put("Result", "here is my first document");
processService.completeWorkItem(activeNodes.iterator().next().getWorkItemId(), outcome);
activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(activeNodes);
assertEquals(2, activeNodes.size());
Object variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_document");
assertNotNull(variableValue);
assertTrue(variableValue instanceof String);
assertEquals("here is my first document", variableValue);
processService.abortProcessInstance(processInstanceId);
pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceEJBIntegrationTest method testStartProcessWithParmsWithCorrelationKey.
@Test
public void testStartProcessWithParmsWithCorrelationKey() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", "test");
CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask", key, params);
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(key);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ClientProcessServiceWithCustomDataEJBTest method testStartProcessWithCustomData.
@Test
public void testStartProcessWithCustomData() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
Map<String, Object> parameters = new RemoteMap();
Object person = getInstance("org.jbpm.test.Person", new Object[] { "john", 25, true });
parameters.put("person", person);
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "custom-data-project.work-on-custom-data", parameters);
assertNotNull(processInstanceId);
List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter(0, 10));
assertNotNull(taskSummaries);
assertEquals(1, taskSummaries.size());
List<Long> tasks = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(tasks);
assertEquals(1, tasks.size());
Long taskId = tasks.get(0);
userTaskService.start(taskId, "john");
Map<String, Object> data = userTaskService.getTaskInputContentByTaskId(taskId);
assertNotNull(data);
Object fromTaskPerson = data.get("_person");
assertNotNull(fromTaskPerson);
assertEquals("john", getFieldValue(fromTaskPerson, "name"));
setFieldValue(fromTaskPerson, "name", "John Doe");
RemoteMap outcome = new RemoteMap();
outcome.put("person_", fromTaskPerson);
userTaskService.complete(taskId, "john", outcome);
ProcessInstanceDesc desc = runtimeDataService.getProcessInstanceById(processInstanceId);
assertNotNull(desc);
assertEquals(2, (int) desc.getState());
processInstanceId = null;
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ClientEjbTimerServiceTest method testStartProcessWithHTDeadline.
@Test
public void testStartProcessWithHTDeadline() throws InterruptedException {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "htdeadlinetest");
List<TaskSummary> krisTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("krisv", new QueryFilter());
assertEquals(1, krisTasks.size());
List<TaskSummary> johnTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertEquals(0, johnTasks.size());
List<TaskSummary> maryTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertEquals(0, maryTasks.size());
// now wait for 2 seconds for first reassignment
Thread.sleep(3000);
krisTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("krisv", new QueryFilter());
assertEquals(0, krisTasks.size());
johnTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertEquals(1, johnTasks.size());
maryTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertEquals(0, maryTasks.size());
userTaskService.start(johnTasks.get(0).getId(), "john");
// now wait for 2 more seconds for second reassignment
Thread.sleep(2000);
krisTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("krisv", new QueryFilter());
assertEquals(0, krisTasks.size());
johnTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertEquals(1, johnTasks.size());
maryTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertEquals(0, maryTasks.size());
// now wait for 1 seconds to make sure that reassignment did not happen any more since task was already started
Thread.sleep(3000);
krisTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("krisv", new QueryFilter());
assertEquals(0, krisTasks.size());
johnTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertEquals(0, johnTasks.size());
maryTasks = runtimeDataService.getTasksAssignedAsPotentialOwner("mary", new QueryFilter());
assertEquals(1, maryTasks.size());
userTaskService.start(maryTasks.get(0).getId(), "mary");
userTaskService.complete(maryTasks.get(0).getId(), "mary", null);
// now wait for 2 seconds to make sure that reassignment did not happen any more since task was completed
Thread.sleep(2000);
ProcessInstance processInstance = processService.getProcessInstance(processInstanceId);
assertNull(processInstance);
processInstanceId = null;
}
Aggregations