DecisionMakerNotStartedItems { public List<Decision> execute(Collection<CommitItem> items) { List<Decision> ret = new ArrayList<>(); if (!isPending(items)) { Collection<CommitItem> notStartedItems = CommitItemUtils.filterItems(items, VerificationStatus.NOT_STARTED); if (!CollectionUtils.isNullOrEmpty(notStartedItems)) { items = CommitItemUtils.refreshItems(items); items = CommitItemUtils.filterNotDone(items); CommitItem currParent = getParent(items, notStartedItems.iterator().next()); for (CommitItem currItem : notStartedItems) { currItem.setParent(currParent); ret.add(new Decision( currItem.getKey(), CollectorApi.getCheckinDecisionHandler(currItem))); currParent = currItem; CollectorApi.getCommitItemContainer().save(currItem); } } } return ret; }  List<Decision> execute(Collection<CommitItem> items);  }
@Test public void testExecute1NotStarted() { List<CommitItem> items = new ArrayList<>(); items.add(CommitItemFactory.create(VerificationStatus.NOT_STARTED)); List<Decision> decisions = new DecisionMakerNotStartedItems().execute(items); Assert.assertEquals(1, decisions.size()); Assert.assertEquals(CheckinDecisionHandler.class, decisions.get(0).getHandler().getClass()); }
@Test public void testExecute1NotStarted1Running1Failed() { List<CommitItem> items = new ArrayList<>(); CommitItem commit1 = CommitItemFactory.create(VerificationStatus.RUNNING); items.add(commit1); CommitItem commit2 = CommitItemFactory.create(VerificationStatus.FAILED); commit2.setParent(commit1); items.add(commit2); CommitItem commit3 = CommitItemFactory.create(VerificationStatus.NOT_STARTED); items.add(commit3); List<Decision> decisions = new DecisionMakerNotStartedItems().execute(items); Assert.assertEquals(0, decisions.size()); }
@Test public void test3NotStarted1Passed() { CommitItem commitItem1 = CommitItemFactory.create(VerificationStatus.PASSED); CommitItem commitItem2 = CommitItemFactory.create(VerificationStatus.NOT_STARTED); CommitItem commitItem3 = CommitItemFactory.create(VerificationStatus.NOT_STARTED); CommitItem commitItem4 = CommitItemFactory.create(VerificationStatus.NOT_STARTED); List<Decision> decisions = new DecisionMakerNotStartedItems().execute(Arrays.asList( commitItem1, commitItem2, commitItem3, commitItem4)); Assert.assertEquals(3, decisions.size()); assertDecision( commitItem2, decisions.get(0), CheckinDecisionHandler.class, CollectorApi.getCommitItemContainer().get(commitItem1.getKey())); assertDecision(commitItem3, decisions.get(1), CheckinDecisionHandler.class, commitItem2); assertDecision(commitItem4, decisions.get(2), CheckinDecisionHandler.class, commitItem3); }