ProcessInstanceDetailsTabPresenter implements ProcessInstanceSummaryAware { @Override public void setProcessInstance(ProcessInstanceSummary process) { view.setProcessDefinitionIdText(""); view.setProcessVersionText(""); view.setProcessDeploymentText(""); view.setCorrelationKeyText(""); view.setActiveTasksListBox(""); view.setStateText(""); view.setCurrentActivitiesListBox(""); view.setParentProcessInstanceIdText("", false); view.setProcessDefinitionIdText(process.getProcessId()); view.setProcessVersionText(process.getProcessVersion()); view.setProcessDeploymentText(process.getDeploymentId()); view.setCorrelationKeyText(process.getCorrelationKey()); if (process.getParentId() > 0) { setParentInstance(process); } else { view.setParentProcessInstanceIdText(constants.No_Parent_Process_Instance(), false); } view.setSlaComplianceText(new SlaStatusConverter().toWidgetValue(process.getSlaCompliance())); view.setStateText(ProcessInstanceStatusUtils.toWidgetValue(process.getState())); if (process.getActiveTasks() != null && !process.getActiveTasks().isEmpty()) { SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); for (UserTaskSummary uts : process.getActiveTasks()) { safeHtmlBuilder.appendEscapedLines(uts.getName() + " (" + uts.getStatus() + ") " + constants.Owner() + ": " + uts.getOwner() + " \n"); } view.setActiveTasksListBox(safeHtmlBuilder.toSafeHtml().asString()); } processRuntimeDataService.call( (final List<NodeInstanceSummary> details) -> { final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); for (NodeInstanceSummary nis : details) { safeHtmlBuilder.appendEscapedLines(nis.getTimestamp() + ": " + nis.getId() + " - " + nis.getName() + " (" + nis.getType() + ") \n"); } view.setCurrentActivitiesListBox(safeHtmlBuilder.toSafeHtml().asString()); } ).getProcessInstanceActiveNodes(process.getProcessInstanceKey()); }  @Inject void setView(final ProcessInstanceDetailsTabView view); @Inject void setProcessRuntimeDataService(final Caller<ProcessRuntimeDataService> processRuntimeDataService); @Inject void setProcessInstanceSelectionEvent(final Event<ProcessInstanceSelectionEvent> processInstanceSelectionEvent); IsWidget getWidget(); @Override void setProcessInstance(ProcessInstanceSummary process); void onProcessInstanceIdSelected(String serverTemplateId, String processDeploymentId, Long parentId);  }
@Test public void setProcessInstanceDetailsTestWihtParentProcessInstance() { ProcessInstanceSummary parentProcessInstanceSummary = getProcessInstanceSummary(); parentProcessInstanceSummary.setParentId(null); parentProcessInstanceSummary.setProcessInstanceId(1L); when(processRuntimeDataServiceMock.getProcessInstance(any())).thenReturn(getProcessInstanceSummary()); presenter.setProcessInstance(processInstanceSummary); verify(view).setProcessDefinitionIdText(processInstanceSummary.getProcessId()); verify(view).setStateText(Constants.INSTANCE.Active()); verify(view).setProcessDeploymentText(processInstanceSummary.getDeploymentId()); verify(view).setProcessVersionText(processInstanceSummary.getProcessVersion()); verify(view).setCorrelationKeyText(processInstanceSummary.getCorrelationKey()); verify(view).setSlaComplianceText(org.jbpm.workbench.common.client.resources.i18n.Constants.INSTANCE.SlaMet()); verify(view).setProcessInstanceDetailsCallback(any()); verify(view).setParentProcessInstanceIdText("", false); verify(view).setParentProcessInstanceIdText("1", true); ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class); verify(view, times(2)).setActiveTasksListBox(argumentCaptor.capture()); assertThat(argumentCaptor.getAllValues()).as("Active user tasks are set").hasSize(2); assertEquals("", argumentCaptor.getAllValues().get(0)); assertThat(argumentCaptor.getAllValues().get(1)) .as("Active user tasks") .contains(userTaskSummary.getName(), userTaskSummary.getStatus(), userTaskSummary.getOwner()); argumentCaptor = ArgumentCaptor.forClass(String.class); verify(view, times(2)).setCurrentActivitiesListBox(argumentCaptor.capture()); assertThat(argumentCaptor.getAllValues()).as("Current Activities are set").hasSize(2); assertEquals("", argumentCaptor.getAllValues().get(0)); assertThat(argumentCaptor.getAllValues().get(1)) .as("Current Activities") .contains(nodeInstanceSummary.getTimestamp().toString(), String.valueOf(nodeInstanceSummary.getId()), nodeInstanceSummary.getName(), nodeInstanceSummary.getType()); }
@Test public void setProcessInstanceDetailsTestWihtoutParentProcessInstance() { when(processRuntimeDataServiceMock.getProcessInstance(any())).thenReturn(null); presenter.setProcessInstance(processInstanceSummary); verify(view).setParentProcessInstanceIdText("", false); verify(view).setParentProcessInstanceIdText("1", false); }