DecisionMakerPassedItems { public List<Decision> execute(Collection<CommitItem> items) { items = CommitItemUtils.refreshItems(items); List<Decision> ret = new ArrayList<>(); Collection<CommitItem> passedItems = CommitItemUtils.filterItems(items, VerificationStatus.PASSED); Collection<CommitItem> forcedItems = CommitItemUtils.filterItems(items, VerificationStatus.FORCING_PUSH); if (!CollectionUtils.isNullOrEmpty(passedItems)) { for (CommitItem currItem : passedItems) { ret.addAll(houseOfCards(currItem)); ret.add(new Decision(currItem.getKey(), new OnSuccessHandler(currItem))); currItem.setDone(true); CollectorApi.getCommitItemContainer().save(currItem); } } if (!CollectionUtils.isNullOrEmpty(forcedItems)) { for (CommitItem currItem : forcedItems) { ret.addAll(houseOfCards(currItem)); ret.add(new Decision(currItem.getKey(), new OnSuccessHandler(currItem))); currItem.setDone(true); CollectorApi.getCommitItemContainer().save(currItem); } } return ret; }  List<Decision> execute(Collection<CommitItem> items);  }
@Test public void testExecute1Pass() { Collection<CommitItem> items = new ArrayList<>(); items.add(CommitItemFactory.create(VerificationStatus.PASSED)); List<Decision> decisions = new DecisionMakerPassedItems().execute(items); Assert.assertEquals(1, decisions.size()); Assert.assertEquals(OnSuccessHandler.class, decisions.get(0).getHandler().getClass()); }
@Test public void testExecuteParent() { Collection<CommitItem> items = new ArrayList<>(); CommitItem item1 = CommitItemFactory.create(VerificationStatus.PASSED); items.add(item1); CommitItem item2 = CommitItemFactory.create(VerificationStatus.RUNNING, item1); items.add(item2); CommitItem item3 = CommitItemFactory.create(VerificationStatus.MERGE_FAILED, item2); items.add(item3); CommitItem item4 = CommitItemFactory.create(VerificationStatus.GIT_FAILURE, item3); item4.setDone(true); items.add(item4); CommitItem item5 = CommitItemFactory.create(VerificationStatus.FAILED, item4); items.add(item5); CommitItem item6 = CommitItemFactory.create(VerificationStatus.PASSED, item5); items.add(item6); List<Decision> decisions = new DecisionMakerPassedItems().execute(items); Assert.assertEquals(4, decisions.size()); assertDecision(item1, decisions.get(0), OnSuccessHandler.class); assertDecision(item5, decisions.get(1), OnSuccessByChildHandler.class); assertDecision(item2, decisions.get(2), OnSuccessByChildHandler.class); assertDecision(item6, decisions.get(3), OnSuccessHandler.class); }