use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class BPMN2DataServicesTest method testObjectVariable.
@Test
public void testObjectVariable() throws IOException {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
String processId = "ObjectVariableProcess";
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
assertNotNull(procDef);
assertEquals(procDef.getId(), "ObjectVariableProcess");
assertEquals(procDef.getName(), "ObjectVariableProcess");
assertEquals(procDef.getKnowledgeType(), "PROCESS");
assertEquals(procDef.getPackageName(), "defaultPackage");
assertEquals(procDef.getType(), "RuleFlow");
assertEquals(procDef.getVersion(), "1");
Map<String, String> processData = bpmn2Service.getProcessVariables(deploymentUnit.getIdentifier(), processId);
assertEquals("String", processData.get("type"));
assertEquals("Object", processData.get("myobject"));
assertEquals(2, processData.keySet().size());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class BPMN2DataServicesTest method testHumanTaskProcess.
@Test
public void testHumanTaskProcess() throws IOException {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
String processId = "org.jbpm.writedocument";
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
assertNotNull(procDef);
assertEquals(procDef.getId(), "org.jbpm.writedocument");
assertEquals(procDef.getName(), "humanTaskSample");
assertEquals(procDef.getKnowledgeType(), "PROCESS");
assertEquals(procDef.getPackageName(), "defaultPackage");
assertEquals(procDef.getType(), "RuleFlow");
assertEquals(procDef.getVersion(), "3");
Map<String, String> processData = bpmn2Service.getProcessVariables(deploymentUnit.getIdentifier(), processId);
assertEquals("String", processData.get("approval_document"));
assertEquals("String", processData.get("approval_translatedDocument"));
assertEquals("String", processData.get("approval_reviewComment"));
assertEquals(3, processData.keySet().size());
Collection<UserTaskDefinition> userTasks = bpmn2Service.getTasksDefinitions(deploymentUnit.getIdentifier(), processId);
assertNotNull(userTasks);
assertEquals(3, userTasks.size());
Map<String, UserTaskDefinition> tasksByName = new HashMap<String, UserTaskDefinition>();
for (UserTaskDefinition userTask : userTasks) {
tasksByName.put(userTask.getName(), userTask);
}
assertTrue(tasksByName.containsKey("Write a Document"));
assertTrue(tasksByName.containsKey("Translate Document"));
assertTrue(tasksByName.containsKey("Review Document"));
UserTaskDefinition task = tasksByName.get("Write a Document");
assertEquals(true, task.isSkippable());
assertEquals("Write a Document", task.getName());
assertEquals(9, task.getPriority().intValue());
assertEquals("Write a Document", task.getComment());
assertEquals("Write a Document", task.getFormName());
assertEquals("2", task.getId());
task = tasksByName.get("Translate Document");
assertEquals(true, task.isSkippable());
assertEquals("Translate Document", task.getName());
assertEquals(0, task.getPriority().intValue());
assertEquals("", task.getComment());
assertEquals("Translate Document", task.getFormName());
assertEquals("4", task.getId());
task = tasksByName.get("Review Document");
assertEquals(false, task.isSkippable());
assertEquals("Review Document", task.getName());
assertEquals(0, task.getPriority().intValue());
assertEquals("", task.getComment());
assertEquals("Review Document", task.getFormName());
assertEquals("5", task.getId());
Map<String, String> taskInputMappings = bpmn2Service.getTaskInputMappings(deploymentUnit.getIdentifier(), processId, "Write a Document");
assertEquals(4, taskInputMappings.keySet().size());
Map<String, String> taskOutputMappings = bpmn2Service.getTaskOutputMappings(deploymentUnit.getIdentifier(), processId, "Write a Document");
assertEquals(1, taskOutputMappings.keySet().size());
Map<String, Collection<String>> associatedEntities = bpmn2Service.getAssociatedEntities(deploymentUnit.getIdentifier(), processId);
assertEquals(3, associatedEntities.keySet().size());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class DeploymentServiceTest method testDeploymentOfProcesses.
@Test
public void testDeploymentOfProcesses() {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(5, processes.size());
processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(processes);
assertEquals(5, processes.size());
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
assertNotNull(manager);
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(engine);
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", "test");
ProcessInstance processInstance = engine.getKieSession().startProcess("customtask", params);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class DeploymentServiceTest method testDeploymentOfProcessesWithActivation.
@Test
public void testDeploymentOfProcessesWithActivation() {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertTrue(deployed.isActive());
assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(5, processes.size());
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
assertNotNull(manager);
// then deactivate it
deploymentService.deactivate(deploymentUnit.getIdentifier());
deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertFalse(deployed.isActive());
processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(0, processes.size());
// and not activate it again
deploymentService.activate(deploymentUnit.getIdentifier());
deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertTrue(deployed.isActive());
processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(5, processes.size());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class DeploymentServiceTest method testDeploymentOfMultipleVersions.
@Test
public void testDeploymentOfMultipleVersions() {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
DeploymentUnit deploymentUnit3 = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, "1.1.0-SNAPSHOT");
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
deploymentService.deploy(deploymentUnit3);
units.add(deploymentUnit3);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
DeployedUnit deployed3 = deploymentService.getDeployedUnit(deploymentUnit3.getIdentifier());
assertNotNull(deployed3);
assertNotNull(deployed3.getDeploymentUnit());
assertNotNull(deployed3.getRuntimeManager());
assertEquals(1, ((DeployedUnitImpl) deployed3).getDeployedClasses().size());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(10, processes.size());
DeployedUnit deployedLatest = deploymentService.getDeployedUnit(GROUP_ID + ":" + ARTIFACT_ID + ":LATEST");
assertNotNull(deployedLatest);
assertNotNull(deployedLatest.getDeploymentUnit());
assertNotNull(deployedLatest.getRuntimeManager());
assertEquals(deploymentUnit3.getIdentifier(), deployedLatest.getDeploymentUnit().getIdentifier());
}
Aggregations