use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class FormProviderServiceImplTest method testGetFormDisplayTask.
@Test
public void testGetFormDisplayTask() {
long taskId = 1;
final TaskImpl task = new TaskImpl();
task.setId(taskId);
task.setName("TaskName");
final TaskDataImpl taskData = new TaskDataImpl();
final String deploymentId = "org.jbpm";
taskData.setDeploymentId(deploymentId);
final String processId = "org.jbpm.evaluation";
taskData.setProcessId(processId);
task.setTaskData(taskData);
when(taskService.getTaskById(taskId)).thenReturn(task);
final ProcessDefinition processDefinition = mock(ProcessDefinition.class);
when(dataService.getProcessesByDeploymentIdProcessId(deploymentId, processId)).thenReturn(processDefinition);
final String form = formProviderService.getFormDisplayTask(1);
assertEquals("", form);
verify(dataService).getProcessesByDeploymentIdProcessId(deploymentId, processId);
verify(formProvider).render(eq(task.getName()), eq(task), eq(processDefinition), anyMap());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testCallActivity.
@Test
public void testCallActivity() throws IOException {
Assume.assumeTrue("Skip call activity tests", loadCallActivityProcesses);
String processId = PROC_ID_CALL_ACTIVITY;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// run process (to verify that it works)
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "oldValue");
Long procId = startProcess(deploymentId, processId, params);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
AuditService auditService = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getAuditService();
List<? extends VariableInstanceLog> logs = auditService.findVariableInstances(procId);
boolean foundY = false;
for (VariableInstanceLog log : logs) {
if (log.getVariableId().equals("y") && log.getValue().equals("new value")) {
foundY = true;
}
}
assertTrue("Parent process did not call sub process", foundY);
// check information about process
Collection<String> refProcesses = bpmn2Service.getReusableSubProcesses(deploymentId, processId);
assertNotNull("Null set of referenced processes", refProcesses);
assertFalse("Empty set of referenced processes", refProcesses.isEmpty());
assertEquals("Number referenced processes", 1, refProcesses.size());
assertEquals("Imported class in processes", PROC_ID_ACTIVITY_CALLED, refProcesses.iterator().next());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testBusinessRuleTask.
@Test
public void testBusinessRuleTask() throws IOException {
Assume.assumeTrue("Skip business rule tests", loadBusinesRuleProcesses);
String processId = PROC_ID_BUSINESS_RULE;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// check that process runs
Person person = new Person();
person.setName("Max Rockatansky");
person.setId(1979l);
person.setTime(3l);
KieSession ksession = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getKieSession();
List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
Long procId = startProcess(deploymentId, processId);
String ruleOutput = "Executed";
assertEquals("Global did not contain output from rule!", 1, list.size());
assertEquals("Global did not contain correct output of rule!", ruleOutput, list.get(0));
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull("Process instance did not complete!", procInst);
// check information about process
Collection<String> refRules = bpmn2Service.getRuleSets(deploymentId, processId);
assertNotNull("Null set of imported rules", refRules);
assertFalse("Empty set of imported rules", refRules.isEmpty());
assertEquals("Number imported rules", 1, refRules.size());
assertEquals("Name of imported ruleset", RULE_BUSINESS_RULE_PROCESS, refRules.iterator().next());
refRules = procDef.getReferencedRules();
assertNotNull("Null set of imported rules", refRules);
assertFalse("Empty set of imported rules", refRules.isEmpty());
assertEquals("Number imported rules", 1, refRules.size());
assertEquals("Name of imported ruleset", RULE_BUSINESS_RULE_PROCESS, refRules.iterator().next());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testCallActivityByName.
@Test
public void testCallActivityByName() throws IOException {
Assume.assumeTrue("Skip call activity tests", loadCallActivityProcesses);
String processId = PROC_ID_CALL_ACTIVITY_BY_NAME;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// run process (to verify that it works)
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "oldValue");
Long procId = startProcess(deploymentId, processId, params);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
AuditService auditService = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getAuditService();
List<? extends VariableInstanceLog> logs = auditService.findVariableInstances(procId);
boolean foundY = false;
for (VariableInstanceLog log : logs) {
if (log.getVariableId().equals("y") && log.getValue().equals("new value")) {
foundY = true;
}
}
assertTrue("Parent process did not call sub process", foundY);
// check information about process
Collection<String> refProcesses = bpmn2Service.getReusableSubProcesses(deploymentId, processId);
assertNotNull("Null set of referenced processes", refProcesses);
assertFalse("Empty set of referenced processes", refProcesses.isEmpty());
assertEquals("Number referenced processes", 1, refProcesses.size());
assertEquals("Imported class in processes", PROC_ID_ACTIVITY_CALLED, refProcesses.iterator().next());
}
use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.
the class BPMN2DataServicesTest method testHumanTaskProcessBeforeAndAfterUndeploy.
@Test
public void testHumanTaskProcessBeforeAndAfterUndeploy() 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");
// now let's undeploy the unit
deploymentService.undeploy(deploymentUnit);
try {
bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
fail("DeploymentNotFoundException was not thrown");
} catch (DeploymentNotFoundException e) {
// expected
}
}
Aggregations