ProcessInstanceDiagramPresenter implements ProcessInstanceSummaryAware { public void onDiagramNodeSelected(final String nodeId) { if (nodeId == null) { view.setValue(new ProcessNodeSummary()); view.setNodeInstances(nodeInstances); view.setTimerInstances(timerInstances); } else { view.setValue(processNodes.stream().filter(node -> node.getUniqueId().equals(nodeId)).findFirst().orElseGet(() -> new ProcessNodeSummary())); view.setNodeInstances(nodeInstances.stream().filter(node -> node.getNodeUniqueName().equals(nodeId)).collect(toList())); view.setTimerInstances(getTimerInstanceForNode(nodeId)); } }  @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 testOnDiagramNodeNullSelected() { presenter.onDiagramNodeSelected(null); verify(view).setValue(new ProcessNodeSummary()); verify(view).setNodeInstances(null); verify(view).setTimerInstances(null); }
@Test public void testOnDiagramNodeSelected() { ProcessInstanceSummary processInstance = ProcessInstanceSummary.builder().withServerTemplateId("serverTemplateId").withDeploymentId("containerId").withProcessInstanceId(1l).withState(ProcessInstance.STATE_ACTIVE).build(); ProcessNodeSummary timerNode = new ProcessNodeSummary(1l, "name-1", "Timer", "_1"); List<ProcessNodeSummary> nodes = Arrays.asList(new ProcessNodeSummary(0l, " ", "Start", "_0"), timerNode, new ProcessNodeSummary(2l, " ", "Split", "_2")); NodeInstanceSummary timerNodeInstance = NodeInstanceSummary.builder().withId(1l).withName("name-1").withNodeUniqueName("_1").withType("Timer").withCompleted(false).build(); List<NodeInstanceSummary> nodeInstances = Arrays.asList( timerNodeInstance, NodeInstanceSummary.builder().withId(2l).withName(" ").withNodeUniqueName("_2").withType("Split").withCompleted(false).build(), NodeInstanceSummary.builder().withId(3l).withName("name-3").withNodeUniqueName("_3").withType("HumanTask").withCompleted(true).build(), NodeInstanceSummary.builder().withId(4l).withName(" ").withNodeUniqueName("_4").withType("End").withCompleted(true).build() ); TimerInstanceSummary timerInstance = TimerInstanceSummary.builder().withId(1l).withTimerId(0l).withName("t1").build(); List<TimerInstanceSummary> timerInstances = Arrays.asList( timerInstance, TimerInstanceSummary.builder().withId(2l).withTimerId(1l).withName("t2").build() ); ProcessInstanceDiagramSummary summary = new ProcessInstanceDiagramSummary(); summary.setProcessDefinition(ProcessSummary.builder().nodes(nodes).timers(singletonList(TimerSummary.builder().id(0l).uniqueId("_1").build())).build()); summary.setNodeInstances(nodeInstances); summary.setTimerInstances(timerInstances); when(processService.getProcessInstanceDiagramSummary(eq(processInstance.getProcessInstanceKey()), anyString(), anyString(), anyString())).thenReturn(summary); presenter.setProcessInstance(processInstance); presenter.onDiagramNodeSelected("_1"); verify(view).setValue(timerNode); verify(view).setNodeInstances(singletonList(timerNodeInstance)); verify(view).setTimerInstances(singletonList(timerInstance)); verify(view).setNodeBadges(any()); verify(view).onShow(); }