FinancingRoundPostProcessor { void assignUnpledgedBudgetToFinancingRound(final FinancingRoundEntity financingRound) { final int pledgedTotalOfRound = pledgeRepository.findByFinancingRound(financingRound).stream() .mapToInt(PledgeEntity::getAmount) .sum(); financingRound.initPostRoundBudget(pledgedTotalOfRound); } @Autowired  FinancingRoundPostProcessor(
            FinancingRoundRepository financingRoundRepository,
            ProjectRepository projectRepository,
            PledgeRepository pledgeRepository); FinancingRoundEntity postProcess(FinancingRoundEntity financingRound);  }
@Test public void assignUnpledgedBudgetToFinancingRound() throws Exception { final FinancingRoundEntity financingRound = prepareInactiveFinancingRound(); financingRoundPostProcessor.assignUnpledgedBudgetToFinancingRound(financingRound); assertThat(financingRound.getPostRoundBudget(), is(EXPECTED_REMAINING_BUDGET_AFTER_ROUND)); }
@Test public void assignUnpledgedBudgetToFinancingRound_setToZeroInCasePledgeAmountBiggerThanBudget() throws Exception { final FinancingRoundEntity financingRound = prepareInactiveFinancingRound(); financingRound.setBudget(project_3.getPledgeGoal()); financingRoundPostProcessor.assignUnpledgedBudgetToFinancingRound(financingRound); assertThat(financingRound.getPostRoundBudget(), is(0)); }