ifs-data-layer/ifs-data-service/src/test/java/org/innovateuk/ifs/project/projectdetails/workflow/ProjectDetailsWorkflowHandlerIntegrationTest.java
/**
     * This asserts that triggering the given handler method with a fully filled in Project will move the process into
     * 'Submitted' state because all the mandatory values are now provided
     */
This asserts that triggering the given handler method with a fully filled in Project will move the process into
'Submitted' state because all the mandatory values are now provided
This asserts that triggering the given handler method with a fully filled in Project will move the process into ' Submitted ' state because all the mandatory values are now provided
private void assertAddMandatoryValueAndNowSubmitted(ProjectDetailsState originalState, BiFunction<Project, ProjectUser, Boolean> handlerFn, ProjectDetailsEvent expectedEvent) {
        Project project = newProject().
                withApplication(newApplication().withCompetition(newCompetition().build()).build()).
                withTargetStartDate(LocalDate.of(2016, 11, 01)).
                withPartnerOrganisations(newPartnerOrganisation().withOrganisation(newOrganisation().build()).withPostcode("POSTCODE").build(1)).
                withAddress(newAddress().build()).
                build();
        ProjectUser projectUser = newProjectUser().withOrganisation(newOrganisation().build()).build();
        ProjectDetailsProcess originalProcess = new ProjectDetailsProcess(projectUser, project, originalState);
        ProjectDetailsProcess updatedProcess = new ProjectDetailsProcess(projectUser, project, originalState);
        when(projectDetailsProcessRepositoryMock.findOneByTargetId(project.getId())).thenReturn(originalProcess);
        when(projectDetailsProcessRepositoryMock.findOneByTargetId(project.getId())).thenReturn(updatedProcess);
        assertTrue(handlerFn.apply(project, projectUser));
        verify(projectDetailsProcessRepositoryMock, atLeastOnce()).findOneByTargetId(project.getId());
        verify(projectDetailsProcessRepositoryMock).save(processExpectations(project.getId(), projectUser.getId(), ProjectDetailsState.SUBMITTED, expectedEvent));
        verifyNoMoreInteractionsWithMocks();
    }
private void assertAddMandatoryValueAndNowSubmitted ( ProjectDetailsState originalState , BiFunction < Project , ProjectUser , Boolean > handlerFn , ProjectDetailsEvent expectedEvent ) { Project project = newProject ( ) . withApplication ( newApplication ( ) . withCompetition ( newCompetition ( ) . build ( ) ) . build ( ) ) . withTargetStartDate ( LocalDate . of ( 2016 , 11 , 01 ) ) . withPartnerOrganisations ( newPartnerOrganisation ( ) . withOrganisation ( newOrganisation ( ) . build ( ) ) . withPostcode ( "POSTCODE" ) . build ( 1 ) ) . withAddress ( newAddress ( ) . build ( ) ) . build ( ) ; ProjectUser projectUser = newProjectUser ( ) . withOrganisation ( newOrganisation ( ) . build ( ) ) . build ( ) ; ProjectDetailsProcess originalProcess = new ProjectDetailsProcess ( projectUser , project , originalState ) ; ProjectDetailsProcess updatedProcess = new ProjectDetailsProcess ( projectUser , project , originalState ) ; when ( projectDetailsProcessRepositoryMock . findOneByTargetId ( project . getId ( ) ) ) . thenReturn ( originalProcess ) ; when ( projectDetailsProcessRepositoryMock . findOneByTargetId ( project . getId ( ) ) ) . thenReturn ( updatedProcess ) ; assertTrue ( handlerFn . apply ( project , projectUser ) ) ; verify ( projectDetailsProcessRepositoryMock , atLeastOnce ( ) ) . findOneByTargetId ( project . getId ( ) ) ; verify ( projectDetailsProcessRepositoryMock ) . save ( processExpectations ( project . getId ( ) , projectUser . getId ( ) , ProjectDetailsState . SUBMITTED , expectedEvent ) ) ; verifyNoMoreInteractionsWithMocks ( ) ; }
This asserts that triggering the given handler method with a fully filled in Project will move the process into
 'Submitted' state because all the mandatory values are now provided
This asserts that triggering the given handler method with a fully filled in Project will move the process into ' Submitted ' state because all the mandatory values are now provided
// now call the method under test