@Test public void testCanDeleteSelection() { Analysis mock1 = mock(Analysis.class); Analysis mock2 = mock(Analysis.class); Analysis mock3 = mock(Analysis.class); Analysis mock4 = mock(Analysis.class); when(mock1.getStatus()).thenReturn(SUBMITTED.toString()); when(mock2.getStatus()).thenReturn(RUNNING.toString()); assertFalse("Selection should not be deletable", uut.canDeleteSelection(Lists.newArrayList(mock1, mock2, mock3))); when(mock1.getStatus()).thenReturn(RUNNING.toString()); when(mock2.getStatus()).thenReturn(COMPLETED.toString()); assertFalse("Selection should not be deletable", uut.canDeleteSelection(Lists.newArrayList(mock3, mock1, mock2))); when(mock1.getStatus()).thenReturn(COMPLETED.toString()); when(mock2.getStatus()).thenReturn(RUNNING.toString()); assertFalse("Selection should not be deletable", uut.canDeleteSelection(Lists.newArrayList(mock1, mock2, mock3))); when(mock1.getStatus()).thenReturn(COMPLETED.toString()); when(mock2.getStatus()).thenReturn(FAILED.toString()); when(mock3.getStatus()).thenReturn(RUNNING.toString()); assertFalse("Selection should not be deletable", uut.canDeleteSelection(Lists.newArrayList(mock1, mock2, mock3))); when(mock1.getStatus()).thenReturn(COMPLETED.toString()); when(mock2.getStatus()).thenReturn(FAILED.toString()); when(mock3.getStatus()).thenReturn(COMPLETED.toString()); when(mock4.getStatus()).thenReturn(CANCELED.toString()); assertTrue("Selection should be deletable", uut.canDeleteSelection(Lists.newArrayList(mock1, mock2, mock3))); }
boolean canDeleteSelection(List<Analysis> selection) { for (Analysis ae : selection) { if (ae == null) continue; final String status = ae.getStatus(); if (!(FAILED.toString().equalsIgnoreCase(status) || COMPLETED.toString().equalsIgnoreCase(status) || CANCELED.toString().equalsIgnoreCase(status))) { return false; } } return true; }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { boolean canDeleteSelection(List<Analysis> selection) { for (Analysis ae : selection) { if (ae == null) continue; final String status = ae.getStatus(); if (!(FAILED.toString().equalsIgnoreCase(status) || COMPLETED.toString().equalsIgnoreCase(status) || CANCELED.toString().equalsIgnoreCase(status))) { return false; } } return true; } }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { boolean canDeleteSelection(List<Analysis> selection) { for (Analysis ae : selection) { if (ae == null) continue; final String status = ae.getStatus(); if (!(FAILED.toString().equalsIgnoreCase(status) || COMPLETED.toString().equalsIgnoreCase(status) || CANCELED.toString().equalsIgnoreCase(status))) { return false; } } return true; } @Inject  AnalysesToolBarImpl(final AnalysesView.Appearance appearance,
                        @Assisted final AnalysesView.Presenter presenter,
                        @Assisted PagingLoader<FilterPagingLoadConfig, PagingLoadResult<Analysis>> loader); }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { boolean canDeleteSelection(List<Analysis> selection) { for (Analysis ae : selection) { if (ae == null) continue; final String status = ae.getStatus(); if (!(FAILED.toString().equalsIgnoreCase(status) || COMPLETED.toString().equalsIgnoreCase(status) || CANCELED.toString().equalsIgnoreCase(status))) { return false; } } return true; } @Inject  AnalysesToolBarImpl(final AnalysesView.Appearance appearance,
                        @Assisted final AnalysesView.Presenter presenter,
                        @Assisted PagingLoader<FilterPagingLoadConfig, PagingLoadResult<Analysis>> loader); @Override void filterByAnalysisId(String analysisId, String name); @Override void filterByParentAnalysisId(String analysisId); @Override void onSelectionChanged(SelectionChangedEvent<Analysis> event); @Override void setFilterInView(AnalysisFilter filter); }
AnalysesToolBarImpl extends Composite implements AnalysisToolBarView { boolean canDeleteSelection(List<Analysis> selection) { for (Analysis ae : selection) { if (ae == null) continue; final String status = ae.getStatus(); if (!(FAILED.toString().equalsIgnoreCase(status) || COMPLETED.toString().equalsIgnoreCase(status) || CANCELED.toString().equalsIgnoreCase(status))) { return false; } } return true; } @Inject  AnalysesToolBarImpl(final AnalysesView.Appearance appearance,
                        @Assisted final AnalysesView.Presenter presenter,
                        @Assisted PagingLoader<FilterPagingLoadConfig, PagingLoadResult<Analysis>> loader); @Override void filterByAnalysisId(String analysisId, String name); @Override void filterByParentAnalysisId(String analysisId); @Override void onSelectionChanged(SelectionChangedEvent<Analysis> event); @Override void setFilterInView(AnalysisFilter filter);  }