Source:
<code>public void testStartProcessInDifferentDeploymentWithAlias() throws Exception { Object person = createPersonInstance(USER_JOHN); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("test", USER_MARY); parameters.put("number", new Integer(12345)); List<Object> list = new ArrayList<Object>(); list.add("item"); parameters.put("list", list); parameters.put("person", person); Long processInstanceIdV1 = null; Long processInstanceIdV2 = null; try { processInstanceIdV1 = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION, parameters); assertNotNull(processInstanceIdV1); assertTrue(processInstanceIdV1.longValue() > 0); ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ALIAS, processInstanceIdV1); assertNotNull(processInstance); assertEquals(CONTAINER_ID, processInstance.getContainerId()); List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); assertEquals(CONTAINER_ID, task.getContainerId()); taskClient.completeAutoProgress(CONTAINER_ALIAS, task.getId(), USER_YODA, null); createExtraContainer(); processInstanceIdV2 = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION, parameters); assertNotNull(processInstanceIdV2); assertTrue(processInstanceIdV2.longValue() > 0); processInstance = processClient.getProcessInstance(CONTAINER_ALIAS, processInstanceIdV2); assertNotNull(processInstance); assertEquals(CONTAINER_ID_101, processInstance.getContainerId()); tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals(CONTAINER_ID_101, task.getContainerId()); taskClient.completeAutoProgress(CONTAINER_ALIAS, task.getId(), USER_YODA, null); } finally { <START> if (processInstanceIdV1 != null) { <END> processClient.abortProcessInstance(CONTAINER_ALIAS, processInstanceIdV1); } if (processInstanceIdV2 != null) { processClient.abortProcessInstance(CONTAINER_ALIAS, processInstanceIdV2); } } }</code><technical_language>I aborting processes done in a separate method variable number of parameters, - moved a @Before method decouple test scenario clean code avoid repetition</technical_language>

Target:
public void testStartProcessInDifferentDeploymentWithAlias() throws Exception { Object person = createPersonInstance(USER_JOHN); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("test", USER_MARY); parameters.put("number", new Integer(12345)); List<Object> list = new ArrayList<Object>(); list.add("item"); parameters.put("list", list); parameters.put("person", person); Long processInstanceIdV1 = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION, parameters); assertNotNull(processInstanceIdV1); assertTrue(processInstanceIdV1.longValue() > 0); ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ALIAS, processInstanceIdV1); assertNotNull(processInstance); assertEquals(CONTAINER_ID, processInstance.getContainerId()); List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); assertEquals(CONTAINER_ID, task.getContainerId()); taskClient.completeAutoProgress(CONTAINER_ALIAS, task.getId(), USER_YODA, null); createExtraContainer(); Long processInstanceIdV2 = processClient.startProcess(CONTAINER_ALIAS, PROCESS_ID_EVALUATION, parameters); assertNotNull(processInstanceIdV2); assertTrue(processInstanceIdV2.longValue() > 0); processInstance = processClient.getProcessInstance(CONTAINER_ALIAS, processInstanceIdV2); assertNotNull(processInstance); assertEquals(CONTAINER_ID_101, processInstance.getContainerId()); tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals(CONTAINER_ID_101, task.getContainerId()); taskClient.completeAutoProgress(CONTAINER_ALIAS, task.getId(), USER_YODA, null); }