@Test public void shouldThrowExceptionIfProgramDoesNotExistWhileGettingProgramSupported() throws Exception { ProgramSupported programSupported = new ProgramSupported(); String fCode = "FCode"; String pCode = "PCode"; programSupported.setFacilityCode(fCode); Program program = new Program(); program.setCode(pCode); programSupported.setProgram(program); Facility facility = new Facility(); facility.setCode(fCode); when(facilityService.getByCode(facility)).thenReturn(facility); when(programService.getByCode(pCode)).thenReturn(null); expectedEx.expect(DataException.class); expectedEx.expectMessage("program.code.invalid"); service.getProgramSupported(programSupported); }
public ProgramSupported getProgramSupported(ProgramSupported programSupported) { Facility facility = getFacility(programSupported); Program program = getProgram(programSupported); return getByFacilityIdAndProgramId(facility.getId(), program.getId()); }
ProgramSupportedService { public ProgramSupported getProgramSupported(ProgramSupported programSupported) { Facility facility = getFacility(programSupported); Program program = getProgram(programSupported); return getByFacilityIdAndProgramId(facility.getId(), program.getId()); } }
ProgramSupportedService { public ProgramSupported getProgramSupported(ProgramSupported programSupported) { Facility facility = getFacility(programSupported); Program program = getProgram(programSupported); return getByFacilityIdAndProgramId(facility.getId(), program.getId()); }  }
ProgramSupportedService { public ProgramSupported getProgramSupported(ProgramSupported programSupported) { Facility facility = getFacility(programSupported); Program program = getProgram(programSupported); return getByFacilityIdAndProgramId(facility.getId(), program.getId()); }  List<ProgramSupported> getAllByFacilityId(Long facilityId); void updateSupportedPrograms(Facility facility); ProgramSupported getFilledByFacilityIdAndProgramId(Long facilityId, Long programId); ProgramSupported getByFacilityIdAndProgramId(Long facilityId, Long programId); void uploadSupportedProgram(ProgramSupported programSupported); ProgramSupported getProgramSupported(ProgramSupported programSupported); void notifyProgramSupportedUpdated(Facility facility); List<ProgramSupported> getActiveByFacilityId(Long facilityId); void updateForVirtualFacilities(Facility parentFacility); }
ProgramSupportedService { public ProgramSupported getProgramSupported(ProgramSupported programSupported) { Facility facility = getFacility(programSupported); Program program = getProgram(programSupported); return getByFacilityIdAndProgramId(facility.getId(), program.getId()); }  List<ProgramSupported> getAllByFacilityId(Long facilityId); void updateSupportedPrograms(Facility facility); ProgramSupported getFilledByFacilityIdAndProgramId(Long facilityId, Long programId); ProgramSupported getByFacilityIdAndProgramId(Long facilityId, Long programId); void uploadSupportedProgram(ProgramSupported programSupported); ProgramSupported getProgramSupported(ProgramSupported programSupported); void notifyProgramSupportedUpdated(Facility facility); List<ProgramSupported> getActiveByFacilityId(Long facilityId); void updateForVirtualFacilities(Facility parentFacility);  }