ProtectedBranchesDecisionMaker { public Collection<List<Decision>> decide() { Collection<List<Decision>> ret = new ArrayList<>(); CommitItem item = null; try { ArrayList<CommitItem> notStarted = new ArrayList<>(CommitItemUtils.filterItems(CommitItemUtils.getNotDone(), VerificationStatus.NOT_STARTED)); Collection<CommitItem> notDone = CommitItemUtils.getNotDone(); notDone.removeAll(notStarted); while(notDone.size()<numberCommits && !notStarted.isEmpty()) { item = notStarted.iterator().next(); notDone.add(item); notStarted.remove(item); } if (!CollectionUtils.isNullOrEmpty(notDone)) { VerigreenLogger.get().log( getClass().getName(), RuntimeUtils.getCurrentMethodName(), String.format("There are %d not done item(s)", notDone.size())); ret = handle(notDone); } } catch (Exception e) { VerigreenLogger.get().error( getClass().getName(), RuntimeUtils.getCurrentMethodName(), String.format("Consumer job has failed."), e); } return ret; }  Collection<List<Decision>> decide();  }
@Test public void testNotStartedItems() { CommitItem commitItem1 = CommitItemFactory.create( VerificationStatus.NOT_STARTED, TestCollectorConstants.PROTECTED_BRANCH_MASTER); CommitItem commitItem2 = CommitItemFactory.create( VerificationStatus.NOT_STARTED, TestCollectorConstants.PROTECTED_BRANCH_1); CommitItem commitItem3 = CommitItemFactory.create( VerificationStatus.NOT_STARTED, TestCollectorConstants.PROTECTED_BRANCH_2); CommitItem commitItem4 = CommitItemFactory.create( VerificationStatus.NOT_STARTED, TestCollectorConstants.PROTECTED_BRANCH_MASTER); Map<String, CommitItem> commits = new HashMap<>(); commits.put(commitItem1.getKey(), commitItem1); commits.put(commitItem2.getKey(), commitItem2); commits.put(commitItem3.getKey(), commitItem3); commits.put(commitItem4.getKey(), commitItem4); Collection<List<Decision>> decisions = new ProtectedBranchesDecisionMaker().decide(); Assert.assertEquals(3, decisions.size()); }