ProcessInstanceAdminServiceImpl implements ProcessInstanceAdminService { @Override public void retriggerNodeInstance(long processInstanceId, long nodeInstanceId) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException { ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); if (pi == null) { throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found"); } processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new RetriggerNodeInstanceCommand(processInstanceId, nodeInstanceId)); } ProcessInstanceAdminServiceImpl(); void setProcessService(ProcessService processService); void setRuntimeDataService(RuntimeDataService runtimeDataService); void setIdentityProvider(IdentityProvider identityProvider); void setCommandService(TransactionalCommandService commandService); @Override Collection<ProcessNode> getProcessNodes(long processInstanceId); @Override void cancelNodeInstance(long processInstanceId, long nodeInstanceId); @Override void retriggerNodeInstance(long processInstanceId, long nodeInstanceId); @Override void updateTimer(long processInstanceId, long timerId, long delay, long period, int repeatLimit); @Override void updateTimerRelative(long processInstanceId, long timerId, long delay, long period, int repeatLimit); @Override Collection<TimerInstance> getTimerInstances(long processInstanceId); @Override void triggerNode(long processInstanceId, long nodeId); @Override Collection<NodeInstanceDesc> getActiveNodeInstances(long processInstanceId); @Override void acknowledgeError(String... errorId); @Override ExecutionError getError(String errorId); @Override List<ExecutionError> getErrors(boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByProcessId(String deploymentId, String processId, boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByProcessInstanceId(long processInstanceId, boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByProcessInstanceId(long processInstanceId, String nodeName, boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByDeploymentId(String containerId, boolean includeAcknowledged, QueryContext queryContext);  }
@Test public void testReTriggerNodeInstance() { processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"); assertNotNull(processInstanceId); Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId); assertNotNull(activeNodes); assertEquals(1, activeNodes.size()); NodeInstanceDesc active = activeNodes.iterator().next(); assertEquals("Write a Document", active.getName()); List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter()); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); processAdminService.retriggerNodeInstance(processInstanceId, active.getId()); activeNodes = processAdminService.getActiveNodeInstances(processInstanceId); assertNotNull(activeNodes); assertEquals(1, activeNodes.size()); Collection<NodeInstanceDesc> completedNodes = runtimeDataService.getProcessInstanceHistoryCompleted(processInstanceId, new QueryFilter()); assertNotNull(completedNodes); assertEquals(1, completedNodes.size()); final List<NodeInstanceDesc> nodeInstances = completedNodes.stream().filter(node -> node.getId().equals(active.getId())).collect(Collectors.toList()); assertEquals(0, nodeInstances.size()); NodeInstanceDesc activeRetriggered = activeNodes.iterator().next(); assertFalse(active.getId().longValue() == activeRetriggered.getId().longValue()); tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter()); assertEquals(1, tasks.size()); TaskSummary taskRetriggered = tasks.get(0); assertFalse(task.getId().longValue() == taskRetriggered.getId().longValue()); }