ProcessInstanceListPresenter extends AbstractMultiGridPresenter<ProcessInstanceSummary, ProcessInstanceListPresenter.ProcessInstanceListView> { public void bulkSignal(List<ProcessInstanceSummary> processInstances) { if (processInstances == null || processInstances.isEmpty()) { return; } final StringBuilder processIdsParam = new StringBuilder(); final StringBuilder deploymentIdsParam = new StringBuilder(); for (ProcessInstanceSummary selected : processInstances) { if (selected.getState() != ProcessInstance.STATE_ACTIVE) { view.displayNotification(constants.Signaling_Process_Instance_Not_Allowed(selected.getId())); continue; } processIdsParam.append(selected.getId() + ","); deploymentIdsParam.append(selected.getDeploymentId() + ","); } if (processIdsParam.length() == 0) { return; } else { processIdsParam.deleteCharAt(processIdsParam.length() - 1); deploymentIdsParam.deleteCharAt(deploymentIdsParam.length() - 1); } PlaceRequest placeRequestImpl = new DefaultPlaceRequest(ProcessInstanceSignalPresenter.SIGNAL_PROCESS_POPUP); placeRequestImpl.addParameter("processInstanceId", processIdsParam.toString()); placeRequestImpl.addParameter("deploymentId", deploymentIdsParam.toString()); placeRequestImpl.addParameter("serverTemplateId", getSelectedServerTemplate()); placeManager.goTo(placeRequestImpl); }  @Inject void setProcessInstanceSelectedEvent(final Event<ProcessInstanceSelectionEvent> processInstanceSelectionEvent); @Override void createListBreadcrumb(); void setupDetailBreadcrumb(String detailLabel); void getDomainSpecifDataForProcessInstances(final Integer startRange,
                                                       final List<ProcessInstanceSummary> instancesFromDataSet,
                                                       final Boolean lastPage); void newInstanceCreated(@Observes final NewProcessInstanceEvent pi); void newInstanceCreated(@Observes final ProcessInstancesUpdateEvent pis); void abortProcessInstance(String containerId,
                                     long processInstanceId); void abortProcessInstances(Map<String, List<Long>> containerInstances); void bulkSignal(List<ProcessInstanceSummary> processInstances); void bulkAbort(List<ProcessInstanceSummary> processInstances); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); void signalProcessInstance(final ProcessInstanceSummary processInstance); @Override void selectSummaryItem(final ProcessInstanceSummary summary); void refreshDetailBreadcrumb(@Observes ProcessInstanceSelectionEvent event); void formClosed(@Observes BeforeClosePlaceEvent closed); @Inject void setFilterSettingsManager(final ProcessInstanceListFilterSettingsManager filterSettingsManager); @Inject void setProcessService(final Caller<ProcessService> processService); @Override void setupActiveSearchFilters(); @Override boolean existActiveSearchFilters(); @Override ActiveFilterItem getActiveFilterFromColumnFilter(ColumnFilter columnFilter); String getStatusColumnFilterDescription(ColumnFilter columnFilter); void openJobsView(final String pid); void openTaskView(final String pid); @Override void openErrorView(final String pid); Predicate<ProcessInstanceSummary> getSignalActionCondition(); Predicate<ProcessInstanceSummary> getAbortActionCondition(); Predicate<ProcessInstanceSummary> getViewJobsActionCondition(); Predicate<ProcessInstanceSummary> getViewTasksActionCondition(); @Override Predicate<ProcessInstanceSummary> getViewErrorsActionCondition();  }
@Test public void bulkSignalProcessInstanceSingleAbortedTest() { ArrayList<ProcessInstanceSummary> processInstanceSummaries = new ArrayList<ProcessInstanceSummary>(); processInstanceSummaries.add(createProcessInstanceSummary(new Random().nextLong(), ProcessInstance.STATE_ABORTED)); presenter.bulkSignal(processInstanceSummaries); verify(placeManager, never()).goTo(any(PlaceRequest.class)); }
@Test public void bulkSignalProcessInstancesStateTest() { processInstanceSummaries.add(createProcessInstanceSummary(new Random().nextLong(), ProcessInstance.STATE_ABORTED)); final List<Long> pIds = new ArrayList<Long>(); for (ProcessInstanceSummary summary : processInstanceSummaries) { if (summary.getState() == ProcessInstance.STATE_ACTIVE) { pIds.add(summary.getProcessInstanceId()); } } presenter.bulkSignal(processInstanceSummaries); final ArgumentCaptor<PlaceRequest> placeRequest = ArgumentCaptor.forClass(PlaceRequest.class); verify(placeManager).goTo(placeRequest.capture()); assertEquals(ProcessInstanceSignalPresenter.SIGNAL_PROCESS_POPUP, placeRequest.getValue().getIdentifier()); assertEquals(StringUtils.join(pIds, ","), placeRequest.getValue().getParameter("processInstanceId", null)); }