@Test public void testGetProcessInstanceSetsActiveTasks() { String containerId = "container"; Long processInstanceId = 1L; boolean withVars = true; String marshallingType = "xstream"; ProcessInstanceDesc processInstanceDesc = new ProcessInstanceDesc(); UserTaskInstanceDesc task1 = new UserTaskInstanceDesc(Long.valueOf(1), "Ready", new Date(), "Task1_name", "Task1_desc", 1, "Task1_Owner", "Task1_Creator", "deployment", "Process", processInstanceId, new Date(), new Date()); UserTaskInstanceDesc task2 = new UserTaskInstanceDesc(Long.valueOf(2), "Ready", new Date(), "Task2_name", "Task2_desc", 1, "Task2_Owner", "Task2_Creator", "deployment", "Process", processInstanceId, new Date(), new Date()); processInstanceDesc.setActiveTasks(Arrays.asList(task1,task2)); processInstanceDesc.setDeploymentId(containerId); when(runtimeDataServiceMock.getProcessInstanceById(processInstanceId)).thenReturn(processInstanceDesc); when(contextMock.getContainerId(eq(containerId),any(ByProcessInstanceIdContainerLocator.class))) .thenReturn(containerId); processServiceBase.getProcessInstance(containerId, processInstanceId, withVars, marshallingType); ArgumentCaptor<org.kie.server.api.model.instance.ProcessInstance> captor =ArgumentCaptor.forClass(org.kie.server.api.model.instance.ProcessInstance.class); verify(marshallerHelperMock).marshal(eq(containerId),eq(marshallingType),captor.capture(),any(ByProcessInstanceIdContainerLocator.class)); org.kie.server.api.model.instance.ProcessInstance processInstance= captor.getValue(); verifyProcessInstanceHasActiveTasks(processInstanceDesc,processInstance); }
public String getProcessInstance(String containerId, Number processInstanceId, boolean withVars, String marshallingType) { ProcessInstanceDesc instanceDesc = runtimeDataService.getProcessInstanceById(processInstanceId.longValue()); if (instanceDesc == null) { throw new ProcessInstanceNotFoundException("Unable to find process instance with id " + processInstanceId); } containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); if (!containerId.equals(instanceDesc.getDeploymentId())) { throwException(instanceDesc.getId(),containerId); } org.kie.server.api.model.instance.ProcessInstance processInstance = convertToProcessInstance(instanceDesc); if (Boolean.TRUE.equals(withVars) && processInstance.getState().equals(ProcessInstance.STATE_ACTIVE)) { Map<String, Object> variables = processService.getProcessInstanceVariables(containerId, processInstanceId.longValue()); processInstance.setVariables(variables); } logger.debug("About to marshal process instance with id '{}' {}", processInstanceId, processInstance); return marshallerHelper.marshal(containerId, marshallingType, processInstance, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); }
ProcessServiceBase { public String getProcessInstance(String containerId, Number processInstanceId, boolean withVars, String marshallingType) { ProcessInstanceDesc instanceDesc = runtimeDataService.getProcessInstanceById(processInstanceId.longValue()); if (instanceDesc == null) { throw new ProcessInstanceNotFoundException("Unable to find process instance with id " + processInstanceId); } containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); if (!containerId.equals(instanceDesc.getDeploymentId())) { throwException(instanceDesc.getId(),containerId); } org.kie.server.api.model.instance.ProcessInstance processInstance = convertToProcessInstance(instanceDesc); if (Boolean.TRUE.equals(withVars) && processInstance.getState().equals(ProcessInstance.STATE_ACTIVE)) { Map<String, Object> variables = processService.getProcessInstanceVariables(containerId, processInstanceId.longValue()); processInstance.setVariables(variables); } logger.debug("About to marshal process instance with id '{}' {}", processInstanceId, processInstance); return marshallerHelper.marshal(containerId, marshallingType, processInstance, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); } }
ProcessServiceBase { public String getProcessInstance(String containerId, Number processInstanceId, boolean withVars, String marshallingType) { ProcessInstanceDesc instanceDesc = runtimeDataService.getProcessInstanceById(processInstanceId.longValue()); if (instanceDesc == null) { throw new ProcessInstanceNotFoundException("Unable to find process instance with id " + processInstanceId); } containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); if (!containerId.equals(instanceDesc.getDeploymentId())) { throwException(instanceDesc.getId(),containerId); } org.kie.server.api.model.instance.ProcessInstance processInstance = convertToProcessInstance(instanceDesc); if (Boolean.TRUE.equals(withVars) && processInstance.getState().equals(ProcessInstance.STATE_ACTIVE)) { Map<String, Object> variables = processService.getProcessInstanceVariables(containerId, processInstanceId.longValue()); processInstance.setVariables(variables); } logger.debug("About to marshal process instance with id '{}' {}", processInstanceId, processInstance); return marshallerHelper.marshal(containerId, marshallingType, processInstance, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); } ProcessServiceBase(ProcessService processService, DefinitionService definitionService, RuntimeDataService runtimeDataService, KieServerRegistry context); }
ProcessServiceBase { public String getProcessInstance(String containerId, Number processInstanceId, boolean withVars, String marshallingType) { ProcessInstanceDesc instanceDesc = runtimeDataService.getProcessInstanceById(processInstanceId.longValue()); if (instanceDesc == null) { throw new ProcessInstanceNotFoundException("Unable to find process instance with id " + processInstanceId); } containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); if (!containerId.equals(instanceDesc.getDeploymentId())) { throwException(instanceDesc.getId(),containerId); } org.kie.server.api.model.instance.ProcessInstance processInstance = convertToProcessInstance(instanceDesc); if (Boolean.TRUE.equals(withVars) && processInstance.getState().equals(ProcessInstance.STATE_ACTIVE)) { Map<String, Object> variables = processService.getProcessInstanceVariables(containerId, processInstanceId.longValue()); processInstance.setVariables(variables); } logger.debug("About to marshal process instance with id '{}' {}", processInstanceId, processInstance); return marshallerHelper.marshal(containerId, marshallingType, processInstance, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); } ProcessServiceBase(ProcessService processService, DefinitionService definitionService, RuntimeDataService runtimeDataService, KieServerRegistry context); void setMarshallerHelper(MarshallerHelper marshallerHelper); String startProcess(String containerId, String processId, String marshallingType); String startProcess(String containerId, String processId, String payload, String marshallingType); String startProcessFromNodeIds(String containerId, String processId, String payload, String marshallingType); String startProcessWithCorrelationKeyFromNodeIds(String containerId, String processId, String correlationKey, String payload, String marshallingType); String startProcessWithCorrelation(String containerId, String processId, String correlationKey, String payload, String marshallingType); Object abortProcessInstance(String containerId, Number processInstanceId); Object abortProcessInstances(String containerId, List<Long> processInstanceIds); void signalProcessInstance(String containerId, Number processInstanceId, String signalName, String marshallingType); void signalProcessInstance(String containerId, Number processInstanceId, String signalName, String eventPayload, String marshallingType); void signalProcessInstances(String containerId, List<Long> processInstanceIds, String signalName, String marshallingType); void signalProcessInstances(String containerId, List<Long> processInstanceIds, String signalName, String eventPayload, String marshallingType); void signal(String containerId, String signalName, String marshallingType); void signal(String containerId, String signalName, String eventPayload, String marshallingType); String getProcessInstance(String containerId,  Number processInstanceId, boolean withVars, String marshallingType); void setProcessVariable(String containerId, Number processInstanceId, String varName, String variablePayload, String marshallingType); void setProcessVariables(String containerId, Number processInstanceId, String variablePayload, String marshallingType); String getProcessInstanceVariable(String containerId, Number processInstanceId, String varName, String marshallingType); String getProcessInstanceVariables(String containerId, Number processInstanceId, String marshallingType); String getAvailableSignals(String containerId, Number processInstanceId, String marshallingType); void completeWorkItem(String containerId, Number processInstanceId, Number workItemId, String resultPayload, String marshallingType); void abortWorkItem(String containerId, Number processInstanceId, Number workItemId); String getWorkItem(String containerId, Number processInstanceId, Number workItemId, String marshallingType); String getWorkItemByProcessInstance(String containerId, Number processInstanceId, String marshallingType); ProcessInstanceList getProcessInstancesByParent(long parentProcessInstanceId, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder); ProcessInstanceList getProcessInstancesByParent(String containerId, long parentProcessInstanceId, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder); }
ProcessServiceBase { public String getProcessInstance(String containerId, Number processInstanceId, boolean withVars, String marshallingType) { ProcessInstanceDesc instanceDesc = runtimeDataService.getProcessInstanceById(processInstanceId.longValue()); if (instanceDesc == null) { throw new ProcessInstanceNotFoundException("Unable to find process instance with id " + processInstanceId); } containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); if (!containerId.equals(instanceDesc.getDeploymentId())) { throwException(instanceDesc.getId(),containerId); } org.kie.server.api.model.instance.ProcessInstance processInstance = convertToProcessInstance(instanceDesc); if (Boolean.TRUE.equals(withVars) && processInstance.getState().equals(ProcessInstance.STATE_ACTIVE)) { Map<String, Object> variables = processService.getProcessInstanceVariables(containerId, processInstanceId.longValue()); processInstance.setVariables(variables); } logger.debug("About to marshal process instance with id '{}' {}", processInstanceId, processInstance); return marshallerHelper.marshal(containerId, marshallingType, processInstance, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); } ProcessServiceBase(ProcessService processService, DefinitionService definitionService, RuntimeDataService runtimeDataService, KieServerRegistry context); void setMarshallerHelper(MarshallerHelper marshallerHelper); String startProcess(String containerId, String processId, String marshallingType); String startProcess(String containerId, String processId, String payload, String marshallingType); String startProcessFromNodeIds(String containerId, String processId, String payload, String marshallingType); String startProcessWithCorrelationKeyFromNodeIds(String containerId, String processId, String correlationKey, String payload, String marshallingType); String startProcessWithCorrelation(String containerId, String processId, String correlationKey, String payload, String marshallingType); Object abortProcessInstance(String containerId, Number processInstanceId); Object abortProcessInstances(String containerId, List<Long> processInstanceIds); void signalProcessInstance(String containerId, Number processInstanceId, String signalName, String marshallingType); void signalProcessInstance(String containerId, Number processInstanceId, String signalName, String eventPayload, String marshallingType); void signalProcessInstances(String containerId, List<Long> processInstanceIds, String signalName, String marshallingType); void signalProcessInstances(String containerId, List<Long> processInstanceIds, String signalName, String eventPayload, String marshallingType); void signal(String containerId, String signalName, String marshallingType); void signal(String containerId, String signalName, String eventPayload, String marshallingType); String getProcessInstance(String containerId,  Number processInstanceId, boolean withVars, String marshallingType); void setProcessVariable(String containerId, Number processInstanceId, String varName, String variablePayload, String marshallingType); void setProcessVariables(String containerId, Number processInstanceId, String variablePayload, String marshallingType); String getProcessInstanceVariable(String containerId, Number processInstanceId, String varName, String marshallingType); String getProcessInstanceVariables(String containerId, Number processInstanceId, String marshallingType); String getAvailableSignals(String containerId, Number processInstanceId, String marshallingType); void completeWorkItem(String containerId, Number processInstanceId, Number workItemId, String resultPayload, String marshallingType); void abortWorkItem(String containerId, Number processInstanceId, Number workItemId); String getWorkItem(String containerId, Number processInstanceId, Number workItemId, String marshallingType); String getWorkItemByProcessInstance(String containerId, Number processInstanceId, String marshallingType); ProcessInstanceList getProcessInstancesByParent(long parentProcessInstanceId, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder); ProcessInstanceList getProcessInstancesByParent(String containerId, long parentProcessInstanceId, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder); static final Logger logger; }