ProcessInstanceSignalPresenter { public void signalProcessInstances(List<Long> processInstanceIds) { if (view.getSignalRefText() == null || view.getSignalRefText().isEmpty()) { view.setHelpText(constants.Signal_Name_Required()); return; } for (Long processInstanceId : processInstanceIds) { view.displayNotification(constants.Signaling_Process_Instance() + " (" + constants.Id() + " = " + processInstanceId + ") " + constants.Signal() + " = " + view.getSignalRefText() + " - " + constants.Signal_Data() + " = " + view.getEventText()); } processService.call((Void v) -> { processInstancesUpdatedEvent.fire(new ProcessInstancesUpdateEvent(0L)); deselectAllItemsEvent.fire(new DeselectAllItemsEvent()); placeManager.closePlace(place); } ).signalProcessInstances(serverTemplateId, Arrays.asList(deploymentId), processInstanceIds, view.getSignalRefText(), view.getEventText()); }  @Inject void setProcessService(final Caller<ProcessService> processService); @OnStartup void onStartup(final PlaceRequest place); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView UberView<ProcessInstanceSignalPresenter> getView(); void signalProcessInstances(List<Long> processInstanceIds); @OnOpen void onOpen(); void getAvailableSignals(long processInstanceId); static final String SIGNAL_PROCESS_POPUP; }
@Test public void signalProcessInstancesEmptyRefTest() { when(view.getSignalRefText()).thenReturn(""); presenter.signalProcessInstances((Arrays.asList(PI_ID))); verify(view).setHelpText(Constants.INSTANCE.Signal_Name_Required()); verifyNoMoreInteractions(processService); }
@Test public void signalProcessInstancesTest() { String signalRef = "SIGNAL_REF"; String eventText = "EVENT_TEXT"; List<Long> processInstanceIds = Arrays.asList(PI_ID, PI_ID2); presenter.onStartup(place); presenter.onOpen(); when(view.getSignalRefText()).thenReturn(signalRef); when(view.getEventText()).thenReturn(eventText); presenter.signalProcessInstances(processInstanceIds); verify(view, times(processInstanceIds.size())).displayNotification(anyString()); verify(view).displayNotification(Constants.INSTANCE.Signaling_Process_Instance() + " (" + Constants.INSTANCE.Id() + " = " + PI_ID + ") " + Constants.INSTANCE.Signal() + " = " + signalRef + " - " + Constants.INSTANCE.Signal_Data() + " = " + eventText); verify(view).displayNotification(Constants.INSTANCE.Signaling_Process_Instance() + " (" + Constants.INSTANCE.Id() + " = " + PI_ID2 + ") " + Constants.INSTANCE.Signal() + " = " + signalRef + " - " + Constants.INSTANCE.Signal_Data() + " = " + eventText); verify(processService).signalProcessInstances(eq(SERVER_TEMPLATE_ID), eq(Arrays.asList(PI_DEPLOYMENT_ID)), eq(processInstanceIds), eq(signalRef), eq(eventText)); verify(placeManager).closePlace(eq(place)); verify(deselectAllItemsEvent).fire(any(DeselectAllItemsEvent.class)); verify(processInstancesUpdatedEvent).fire(any(ProcessInstancesUpdateEvent.class)); }