@Test public void shouldReturnExistingRecordIfAlreadyInitialized() throws Exception{ VaccineReport report = make(a(VaccineReportBuilder.defaultVaccineReport)); when(repository.getByProgramPeriod(1L, 1L, 1L)).thenReturn(report); VaccineReport result = service.initialize(1L, 1L, 1L, 1L); verify(programProductService, never() ).getActiveByProgram(1L); assertThat(result, is(report)); }
@Transactional public VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId) { VaccineReport report = repository.getByProgramPeriod(facilityId, programId, periodId); if (report != null) { return report; } report = createNewVaccineReport(facilityId, programId, periodId); repository.insert(report); ReportStatusChange change = new ReportStatusChange(report, ReportStatus.DRAFT, userId); reportStatusChangeRepository.insert(change); return report; }
VaccineReportService { @Transactional public VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId) { VaccineReport report = repository.getByProgramPeriod(facilityId, programId, periodId); if (report != null) { return report; } report = createNewVaccineReport(facilityId, programId, periodId); repository.insert(report); ReportStatusChange change = new ReportStatusChange(report, ReportStatus.DRAFT, userId); reportStatusChangeRepository.insert(change); return report; } }
VaccineReportService { @Transactional public VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId) { VaccineReport report = repository.getByProgramPeriod(facilityId, programId, periodId); if (report != null) { return report; } report = createNewVaccineReport(facilityId, programId, periodId); repository.insert(report); ReportStatusChange change = new ReportStatusChange(report, ReportStatus.DRAFT, userId); reportStatusChangeRepository.insert(change); return report; }  }
VaccineReportService { @Transactional public VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId) { VaccineReport report = repository.getByProgramPeriod(facilityId, programId, periodId); if (report != null) { return report; } report = createNewVaccineReport(facilityId, programId, periodId); repository.insert(report); ReportStatusChange change = new ReportStatusChange(report, ReportStatus.DRAFT, userId); reportStatusChangeRepository.insert(change); return report; }  @Transactional VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId); @Transactional void save(VaccineReport report, Long userId); @Transactional void submit(VaccineReport report, Long userId); List<ReportStatusDTO> getReportedPeriodsFor(Long facilityId, Long programId); List<ReportStatusDTO> getPeriodsFor(Long facilityId, Long programId, Date endDate); VaccineReport getById(Long id); Long getReportIdForFacilityAndPeriod(Long facilityId, Long periodId); List<HashMap<String, Object>> vaccineUsageTrend(String facilityCode, String productCode, Long periodId, Long zoneId); Map<String, Object> getMonthlyVaccineReport(Long facilityId, Long periodId, Long zoneId); }
VaccineReportService { @Transactional public VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId) { VaccineReport report = repository.getByProgramPeriod(facilityId, programId, periodId); if (report != null) { return report; } report = createNewVaccineReport(facilityId, programId, periodId); repository.insert(report); ReportStatusChange change = new ReportStatusChange(report, ReportStatus.DRAFT, userId); reportStatusChangeRepository.insert(change); return report; }  @Transactional VaccineReport initialize(Long facilityId, Long programId, Long periodId, Long userId); @Transactional void save(VaccineReport report, Long userId); @Transactional void submit(VaccineReport report, Long userId); List<ReportStatusDTO> getReportedPeriodsFor(Long facilityId, Long programId); List<ReportStatusDTO> getPeriodsFor(Long facilityId, Long programId, Date endDate); VaccineReport getById(Long id); Long getReportIdForFacilityAndPeriod(Long facilityId, Long periodId); List<HashMap<String, Object>> vaccineUsageTrend(String facilityCode, String productCode, Long periodId, Long zoneId); Map<String, Object> getMonthlyVaccineReport(Long facilityId, Long periodId, Long zoneId); static final String VACCINE_REPORT_VACCINE_CATEGORY_CODE; static final String VACCINE_REPORT_VITAMINS_CATEGORY_CODE; static final String VACCINE_REPORT_SYRINGES_CATEGORY_CODE; }