ProcessInstanceDiagramPresenter implements ProcessInstanceSummaryAware { protected void loadProcessInstanceDetails() { processService.call((ProcessInstanceDiagramSummary summary) -> { displayImage(summary.getSvgContent(), processInstance.getDeploymentId()); processNodes = summary.getProcessDefinition().getNodes().stream().sorted(comparing(ProcessNodeSummary::getName, String.CASE_INSENSITIVE_ORDER).thenComparingLong(ProcessNodeSummary::getId)).collect(toList()); processNodes.stream().filter(this::isProcessNodeTypeTriggerAllowed).forEach(pn -> pn.addCallback(constants.Trigger(), () -> onProcessNodeTrigger(pn))); view.setProcessNodes(processNodes); view.setShowOrHideParentAndSubProcessPanelCommand(() -> showOrHideParentAndSubProcessPanel(summary.getParentProcessInstanceSummary(), summary.getSubProcessInstances())); nodeInstances = summary.getNodeInstances().stream().sorted(comparing(NodeInstanceSummary::getName, String.CASE_INSENSITIVE_ORDER).thenComparingLong(NodeInstanceSummary::getId)).collect(toList()); nodeInstances.forEach(ni -> { ni.setDescription((ni.isCompleted() ? constants.Completed() : constants.Started()) + " " + DateUtils.getPrettyTime(ni.getTimestamp())); if (ni.isCompleted() == false) { ni.addCallback(constants.Cancel(), () -> onNodeInstanceCancel(ni)); ni.addCallback(constants.ReTrigger(), () -> onNodeInstanceReTrigger(ni)); } }); final Map<String, Long> badges = nodeInstances.stream().collect(Collectors.groupingBy(NodeInstanceSummary::getNodeUniqueName, Collectors.counting())); view.setNodeBadges(badges); view.setNodeInstances(nodeInstances); view.showOrHideParentAndSubProcessPanelTriggered(); view.setSubProcessInstances(summary.getSubProcessInstances()); view.setParentProcessInstance(summary.getParentProcessInstanceSummary()); view.setParentSelectedCommand(() -> listenParentProcessInstanceSelected()); timerInstances = summary.getTimerInstances().stream().sorted(comparing(TimerInstanceSummary::getName, String.CASE_INSENSITIVE_ORDER).thenComparingLong(TimerInstanceSummary::getId)).collect(toList()); timerInstances.forEach(ti -> { ti.setDescription(constants.NextExecution() + " " + DateUtils.getPrettyTime(ti.getNextFireTime())); ti.addCallback(constants.Reschedule(), () -> { rescheduleView.setOnReschedule(timer -> onTimerInstanceReschedule(timer)); rescheduleView.setValue(ti); rescheduleView.show(); }); }); view.setTimerInstances(timerInstances); view.setShowOrHideNodeActionsCommand(() -> showOrHideNodeActions(forLog, processInstance)); timers = summary.getProcessDefinition().getTimers().stream().collect(toList()); view.showOrHideNodeActionsTriggered(); expandDiagram(processInstance, summary); view.onShow(); }).getProcessInstanceDiagramSummary(processInstance.getProcessInstanceKey(), preferences.getProcessInstanceDiagramCompletedNodeColor(), preferences.getProcessInstanceDiagramCompletedNodeBorderColor(), preferences.getProcessInstanceDiagramActiveNodeBorderColor()); }  @PostConstruct void init(); @Override void setProcessInstance(ProcessInstanceSummary processInstance); void onProcessInstanceSelectionEvent(@Observes final ProcessInstanceSelectionEvent event); void displayImage(final String svgContent, final String containerId); void onDiagramNodeSelected(final String nodeId); void onProcessNodeTrigger(final ProcessNodeSummary node); void listenParentProcessInstanceSelected(); void onNodeInstanceReTrigger(final NodeInstanceSummary node); void onNodeInstanceCancel(final NodeInstanceSummary node); void onTimerInstanceReschedule(final TimerInstanceSummary summary); void onShow(); @WorkbenchPartTitle String getName(); @WorkbenchPartView IsWidget getView(); @Inject void setProcessService(final Caller<ProcessRuntimeDataService> processService); void onProcessDiagramExpandEvent(@Observes ProcessDiagramExpandEvent event);  }
@Test public void testLoadProcessInstanceDetails() { ProcessInstanceDiagramSummary summary = createHumanTaskProcessInstanceDiagramSummary(null); ProcessInstanceSummary processInstance = ProcessInstanceSummary.builder().withServerTemplateId("serverTemplateId").withDeploymentId("containerId").withProcessInstanceId(1L).withState(ProcessInstance.STATE_ACTIVE).build(); String completeNodeColor = "#888888"; String completeNodeBorderColor = "#888887"; String activeNodeBorderColor = "#888886"; when(preferences.getProcessInstanceDiagramCompletedNodeColor()).thenReturn(completeNodeColor); when(preferences.getProcessInstanceDiagramCompletedNodeBorderColor()).thenReturn(completeNodeBorderColor); when(preferences.getProcessInstanceDiagramActiveNodeBorderColor()).thenReturn(activeNodeBorderColor); when(processService.getProcessInstanceDiagramSummary(eq(processInstance.getProcessInstanceKey()), anyString(), anyString(), anyString())).thenReturn(summary); presenter.setProcessInstance(processInstance); verify(view, times(2)).setProcessNodes(any()); verify(view).setShowOrHideNodeActionsCommand(any()); verify(view).setShowOrHideParentAndSubProcessPanelCommand(any()); verify(view).showOrHideParentAndSubProcessPanelTriggered(); verify(view, never()).expandDiagram(); verify(view, never()).disableExpandAnchor(); verify(view).showOrHideNodeActionsTriggered(); }