RequestListPresenter extends AbstractMultiGridPresenter<RequestSummary, RequestListPresenter.RequestListView> { protected Command getNewJobCommand() { if (newJobCommand == null) { newJobCommand = () -> { final String selectedServerTemplate = getSelectedServerTemplate(); if (selectedServerTemplate == null || selectedServerTemplate.trim().isEmpty()) { view.displayNotification(constants.SelectServerTemplate()); } else { newJobPresenter.openNewJobDialog(selectedServerTemplate); } }; } return newJobCommand; } RequestListPresenter();  RequestListPresenter(RequestListViewImpl view,
                                Caller<ExecutorService> executorServices,
                                DataSetQueryHelper dataSetQueryHelper,
                                Event<RequestChangedEvent> requestChangedEvent,
                                Event<JobSelectedEvent> jobSelectedEvent,
                                PlaceManager placeManager); @Inject void setFilterSettingsManager(final JobListFilterSettingsManager filterSettingsManager); @Override void createListBreadcrumb(); void setupDetailBreadcrumb(String detailLabel); void cancelRequest(final String deploymentId,
                              final Long requestId); void requeueRequest(final String deploymentId,
                               final Long requestId); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @Override void selectSummaryItem(final RequestSummary job); void requestCreated(@Observes RequestChangedEvent event); @Override void setupActiveSearchFilters(); @Override boolean existActiveSearchFilters(); @Override ActiveFilterItem getActiveFilterFromColumnFilter(ColumnFilter columnFilter); String getStatusColumnFilterDescription(ColumnFilter columnFilter); void openProcessInstanceView(final String processInstanceId); Predicate<RequestSummary> getCancelActionCondition(); Predicate<RequestSummary> getRequeueActionCondition(); Predicate<RequestSummary> getViewProcessActionCondition(); void bulkCancel(List<RequestSummary> jobsSelected); void bulkRequeue(List<RequestSummary> jobsSelected);  }
@Test public void testOpenNewJobDialog_serverTemplateNull() { presenter.setSelectedServerTemplate(null); assertNotNull(presenter.getNewJobCommand()); presenter.getNewJobCommand().execute(); verify(viewMock).displayNotification("SelectServerTemplate"); verify(newJobPresenterMock, never()).openNewJobDialog(anyString()); }
@Test public void testOpenNewJobDialog_serverTemplateEmpty() { assertTrue(presenter.getSelectedServerTemplate().isEmpty()); assertNotNull(presenter.getNewJobCommand()); presenter.getNewJobCommand().execute(); verify(viewMock).displayNotification("SelectServerTemplate"); verify(newJobPresenterMock, never()).openNewJobDialog(anyString()); }
@Test public void testOpenNewJobDialog_serverTemplateSet() { final String serverTemplateTest = "serverTemplateTest"; presenter.setSelectedServerTemplate(new ServerTemplate(serverTemplateTest, null, singletonList(Capability.PROCESS.name()), emptyMap(), emptyList())); assertNotNull(presenter.getNewJobCommand()); presenter.getNewJobCommand().execute(); assertEquals(serverTemplateTest, presenter.getSelectedServerTemplate()); verify(newJobPresenterMock).openNewJobDialog(serverTemplateTest); verify(viewMock, times(3)).getListGrid(); verify(viewMock).clearBlockingError(); verifyNoMoreInteractions(viewMock); }