CommitItemUtils { public static Collection<CommitItem> filterItems( Collection<CommitItem> items, final VerificationStatus state) { return CollectionUtils.isNullOrEmpty(items) ? new ArrayList<CommitItem>() : Collections2.filter(items, new Predicate<CommitItem>() { @Override public boolean apply(CommitItem input) { return input != null ? input.getStatus().equals(state) : false; } }); } private  CommitItemUtils(); static Collection<CommitItem> filterItems(
            Collection<CommitItem> items,
            final VerificationStatus state); static Collection<CommitItem> getNotDone(); static Collection<CommitItem> getRunning(); static Collection<CommitItem> filterNotDone(Collection<CommitItem> items); static Collection<CommitItem> refreshItems(Collection<CommitItem> items); static void createJsonFile(CommitItem localCommitItem, boolean canceledItem);  }
@Test public void testFilterItemsNull() { Collection<CommitItem> items = CommitItemUtils.filterItems(null, VerificationStatus.PASSED); Assert.assertTrue(CollectionUtils.isNullOrEmpty(items)); }
@Test public void testFilterItemsEmpty() { Collection<CommitItem> items = CommitItemUtils.filterItems( Collections.<CommitItem> emptyList(), VerificationStatus.PASSED); Assert.assertTrue(CollectionUtils.isNullOrEmpty(items)); }
@Test public void testFilterItemsAllPassed() { Collection<CommitItem> items = CommitItemUtils.filterItems( Arrays.asList( CommitItemFactory.create(VerificationStatus.PASSED), CommitItemFactory.create(VerificationStatus.PASSED)), VerificationStatus.PASSED); verify(items, 2); }
@Test public void testFilterItemsPassedFailed() { Collection<CommitItem> items = CommitItemUtils.filterItems( Arrays.asList( CommitItemFactory.create(VerificationStatus.PASSED), CommitItemFactory.create(VerificationStatus.FAILED), CommitItemFactory.create(VerificationStatus.GIT_FAILURE), CommitItemFactory.create(VerificationStatus.PASSED)), VerificationStatus.PASSED); verify(items, 2); }
@Test public void testFilterItemsPassedAndEmpty() { Collection<CommitItem> items = CommitItemUtils.filterItems(Arrays.asList( CommitItemFactory.create(VerificationStatus.PASSED), CommitItem.EMPTY, null), VerificationStatus.PASSED); verify(items, 1); }