FinancingRoundPostProcessor { void notifyProjectsOfTerminatedFinancingRound(final FinancingRoundEntity financingRound) { projectRepository.findByFinancingRound(financingRound).stream() .forEach(project -> { if (project.onFinancingRoundTerminated(financingRound)) { projectRepository.save(project); } }); } @Autowired  FinancingRoundPostProcessor(
            FinancingRoundRepository financingRoundRepository,
            ProjectRepository projectRepository,
            PledgeRepository pledgeRepository); FinancingRoundEntity postProcess(FinancingRoundEntity financingRound);  }
@Test public void notifyProjectsOfTerminatedFinancingRound() throws Exception { final FinancingRoundEntity terminatedRound = prepareInactiveFinancingRound(); project_0.setFinancingRound(terminatedRound); project_1.setFinancingRound(terminatedRound); project_2.setFinancingRound(null); project_3.setFinancingRound(terminatedRound); financingRoundPostProcessor.notifyProjectsOfTerminatedFinancingRound(terminatedRound); verify(projectRepository).findByFinancingRound(eq(terminatedRound)); verify(projectRepository).save(any(ProjectEntity.class)); assertThat(project_0.getStatus(), is(ProjectStatus.PUBLISHED)); assertThat(project_0.getFinancingRound(), is(nullValue())); assertThat(project_1.getStatus(), is(ProjectStatus.FULLY_PLEDGED)); assertThat(project_1.getFinancingRound(), is(terminatedRound)); assertThat(project_2.getStatus(), is(ProjectStatus.DEFERRED)); assertThat(project_2.getFinancingRound(), is(nullValue())); assertThat(project_3.getStatus(), is(ProjectStatus.PUBLISHED)); assertThat(project_3.getFinancingRound(), is(terminatedRound)); }