JBPM 6 - 2.2 - User Task

From Training Material
Jump to navigation Jump to search

JBPM 6 - 2.2 - User Task

public class ProcessTestEmpRec extends JbpmJUnitBaseTestCase {

	@Test
	public void testProcess() {
		RuntimeManager manager = createRuntimeManager("emp_recruitment1.bpmn2");
		RuntimeEngine engine = getRuntimeEngine(null);
		KieSession ksession = engine.getKieSession();
		TaskService taskService = engine.getTaskService();
		
		ProcessInstance processInstance = ksession.startProcess("hrproj.employee_recruitment");

		assertProcessInstanceActive(processInstance.getId(), ksession);
		
		// Executing PhoneInterview task
		List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("krisv", "en-UK");
		TaskSummary task = list.get(0);
		System.out.println("Kris is executing task " + task.getName());
		taskService.start(task.getId(), "krisv");
		taskService.complete(task.getId(), "krisv", null);
		
		assertNodeTriggered(processInstance.getId(), "PhoneInterview");

		assertProcessInstanceCompleted(processInstance.getId(), ksession);
		
		manager.disposeRuntimeEngine(engine);
		manager.close();
	}
	public ProcessTestEmpRec() {
		  super(true, true, "org.jbpm.persistence.jpa.updated");  
	}
}

Execise

  1. Write tests for emp_recuritment4 covering all possible paths