ProgramObjectBundleHook extends
    AbstractObjectBundleHook { @Override public void postCreate( IdentifiableObject object, ObjectBundle bundle ) { if ( !isProgram( object ) ) { return; } syncSharingForEventProgram( (Program) object ); addProgramInstance( (Program) object ); updateProgramStage( (Program) object ); } ProgramObjectBundleHook( ProgramInstanceService programInstanceService, ProgramService programService,
        ProgramStageService programStageService, AclService aclService ); @Override void postCreate( IdentifiableObject object, ObjectBundle bundle ); @Override void postUpdate( IdentifiableObject object, ObjectBundle bundle ); @Override List<ErrorReport> validate( T object, ObjectBundle bundle );  }
@Test public void verifyUpdateProgramStage() { ProgramStage programStage = createProgramStage( 'A', 1 ); programA.getProgramStages().add( programStage ); ArgumentCaptor<Program> argument = ArgumentCaptor.forClass( Program.class ); ArgumentCaptor<ProgramStage> argPS = ArgumentCaptor.forClass( ProgramStage.class ); programService.addProgram( programA ); subject.postCreate( programA, null ); verify( programService ).updateProgram( argument.capture() ); verify( programStageService ).saveProgramStage( argPS.capture() ); assertThat( argPS.getValue().getName(), is( equalToIgnoringCase( "ProgramStageA" ) ) ); assertThat( argPS.getValue().getProgram(), is( programA ) ); assertThat( argument.getValue().getName(), is( equalToIgnoringCase( "ProgramA" ) ) ); assertThat( argument.getValue().getProgramStages().size(), is( 1 ) ); assertThat( argument.getValue().getProgramStages().iterator().next().getName(), is( equalToIgnoringCase( "ProgramStageA" ) ) ); }