ProcessInstanceDiagramPresenter implements ProcessInstanceSummaryAware { public void onProcessInstanceSelectionEvent(@Observes final ProcessInstanceSelectionEvent event) { forLog = event.isForLog(); }  @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 testOnProcessInstanceSelectionEvent() { ProcessInstanceSummary processInstance = ProcessInstanceSummary.builder().withServerTemplateId("serverTemplateId").withDeploymentId("containerId").withProcessInstanceId(1l).withState(ProcessInstance.STATE_ACTIVE).build(); String svgContent = "<svg></svg>"; List<ProcessNodeSummary> nodes = Arrays.asList(new ProcessNodeSummary(1l, " ", "StartNode", "_1"), new ProcessNodeSummary(2l, "task-name", "HumanTask", "_2"), new ProcessNodeSummary(3l, " ", "Split", "_3")); List<NodeInstanceSummary> nodeInstances = Arrays.asList( NodeInstanceSummary.builder().withId(1l).withName("name-1").withNodeUniqueName("_1").withType("HumanTask").withCompleted(false).build(), 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() ); List<TimerInstanceSummary> timerInstances = Arrays.asList( TimerInstanceSummary.builder().withId(2l).withName("t2").build(), TimerInstanceSummary.builder().withId(1l).withName("t1").build()); ProcessInstanceDiagramSummary summary = new ProcessInstanceDiagramSummary(); summary.setSvgContent(svgContent); summary.setProcessDefinition(ProcessSummary.builder().nodes(nodes).timers(emptyList()).build()); summary.setNodeInstances(nodeInstances); summary.setTimerInstances(timerInstances); when(processService.getProcessInstanceDiagramSummary(eq(processInstance.getProcessInstanceKey()), anyString(), anyString(), anyString())).thenReturn(summary); presenter.setProcessInstance(processInstance); verify(view).showBusyIndicator(any()); ArgumentCaptor<List> nodesCaptor = ArgumentCaptor.forClass(List.class); verify(view, times(2)).setProcessNodes(nodesCaptor.capture()); assertThat(nodesCaptor.getAllValues().get(0)).isEmpty(); final List<ProcessNodeSummary> viewNodes = nodesCaptor.getAllValues().get(1); assertThat(viewNodes).hasSameSizeAs(nodes); assertThat(viewNodes.get(0).getLabel()).isEqualTo("Split-3"); assertThat(viewNodes.get(0).getName()).isEqualTo("Split"); assertThat(viewNodes.get(0).getType()).isEqualTo("Split"); assertThat(viewNodes.get(0).getUniqueId()).isEqualTo("_3"); assertThat(viewNodes.get(0).getCallbacks()).hasSize(1); assertThat(viewNodes.get(1).getLabel()).isEqualTo("StartNode-1"); assertThat(viewNodes.get(1).getName()).isEqualTo("StartNode"); assertThat(viewNodes.get(1).getType()).isEqualTo("StartNode"); assertThat(viewNodes.get(1).getUniqueId()).isEqualTo("_1"); assertThat(viewNodes.get(1).getCallbacks()).isNullOrEmpty(); assertThat(viewNodes.get(2).getLabel()).isEqualTo("task-name-2"); assertThat(viewNodes.get(2).getName()).isEqualTo("task-name"); assertThat(viewNodes.get(2).getType()).isEqualTo("HumanTask"); assertThat(viewNodes.get(2).getUniqueId()).isEqualTo("_2"); assertThat(viewNodes.get(2).getCallbacks()).hasSize(1); ArgumentCaptor<List> nodeInstancesCaptor = ArgumentCaptor.forClass(List.class); verify(view, times(2)).setNodeInstances(nodeInstancesCaptor.capture()); assertThat(nodeInstancesCaptor.getAllValues().get(0)).isEmpty(); final List<NodeInstanceSummary> viewNodeInstances = nodeInstancesCaptor.getAllValues().get(1); assertThat(viewNodeInstances).hasSameSizeAs(nodeInstances); assertThat(viewNodeInstances.get(0).getLabel()).isEqualTo("End-4"); assertThat(viewNodeInstances.get(0).getName()).isEqualTo("End"); assertThat(viewNodeInstances.get(0).getType()).isEqualTo("End"); assertThat(viewNodeInstances.get(0).getDescription()).startsWith("Completed"); assertThat(viewNodeInstances.get(0).getCallbacks()).isNullOrEmpty(); assertThat(viewNodeInstances.get(1).getLabel()).isEqualTo("name-1-1"); assertThat(viewNodeInstances.get(1).getName()).isEqualTo("name-1"); assertThat(viewNodeInstances.get(1).getType()).isEqualTo("HumanTask"); assertThat(viewNodeInstances.get(1).getDescription()).startsWith("Started"); assertThat(viewNodeInstances.get(1).getCallbacks()).hasSize(2); assertThat(viewNodeInstances.get(2).getLabel()).isEqualTo("name-3-3"); assertThat(viewNodeInstances.get(2).getName()).isEqualTo("name-3"); assertThat(viewNodeInstances.get(2).getType()).isEqualTo("HumanTask"); assertThat(viewNodeInstances.get(2).getDescription()).startsWith("Completed"); assertThat(viewNodeInstances.get(2).getCallbacks()).isNullOrEmpty(); assertThat(viewNodeInstances.get(3).getLabel()).isEqualTo("Split-2"); assertThat(viewNodeInstances.get(3).getName()).isEqualTo("Split"); assertThat(viewNodeInstances.get(3).getType()).isEqualTo("Split"); assertThat(viewNodeInstances.get(3).getDescription()).startsWith("Started"); assertThat(viewNodeInstances.get(3).getCallbacks()).hasSize(2); ArgumentCaptor<List> timerInstancesCaptor = ArgumentCaptor.forClass(List.class); verify(view, times(2)).setTimerInstances(timerInstancesCaptor.capture()); assertThat(timerInstancesCaptor.getAllValues().get(0)).isEmpty(); final List<TimerInstanceSummary> viewTimerInstances = timerInstancesCaptor.getAllValues().get(1); assertThat(viewTimerInstances).hasSameSizeAs(timerInstances); assertThat(viewTimerInstances.get(0).getLabel()).isEqualTo("t1-1"); assertThat(viewTimerInstances.get(0).getName()).isEqualTo("t1"); assertThat(viewTimerInstances.get(0).getDescription()).startsWith("NextExecution"); assertThat(viewTimerInstances.get(0).getCallbacks()).hasSize(1); assertThat(viewTimerInstances.get(1).getLabel()).isEqualTo("t2-2"); assertThat(viewTimerInstances.get(1).getName()).isEqualTo("t2"); assertThat(viewTimerInstances.get(1).getDescription()).startsWith("NextExecution"); assertThat(viewTimerInstances.get(1).getCallbacks()).hasSize(1); ArgumentCaptor<Map> badgesInstancesCaptor = ArgumentCaptor.forClass(Map.class); verify(view).setNodeBadges(badgesInstancesCaptor.capture()); final Map<String, Long> badges = badgesInstancesCaptor.getValue(); assertThat(badges).containsExactly(immutableEntry("_1", 1l), immutableEntry("_2", 1l), immutableEntry("_3", 1l), immutableEntry("_4", 1l)); }