Skip to content

Commit

Permalink
added pull period by suggested period from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanhussein committed Jul 27, 2024
1 parent 29435fe commit 133e86c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,12 @@ public ProcessingPeriodDto findPeriod(UUID programId, UUID facilityId, UUID sugg

if (suggestedPeriodId != null && period != null) {

ProcessingPeriodDto proposedPeriod = periodReferenceDataService
.searchById(suggestedPeriodId);
ProcessingPeriodDto
proposedPeriod = getPeriod(suggestedPeriodId);

if (!proposedPeriod.getId().equals(period.getId())) {
if (proposedPeriod != null && !proposedPeriod.getId()
.equals(period.getId())) {
period = proposedPeriod;
} else {
throw new ValidationMessageException(new Message(
ERROR_PERIOD_SHOULD_BE_OLDEST_AND_NOT_ASSOCIATED));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,9 @@ public void shouldThrowExceptionIfPeriodIsNotTheOldest() {

mockSupportedProgramStartDateNotSet();
when(periodReferenceDataService.searchByProgramAndFacility(programId, facilityId))
.thenReturn(Lists.newArrayList(currentPeriod));

when(periodReferenceDataService.searchById(currentPeriod.getId()))
.thenReturn(currentPeriod);
.thenReturn(null);

periodService.findPeriod(programId, facilityId, currentPeriod.getId(), false);
periodService.findPeriod(programId, facilityId, UUID.randomUUID(), false);
}

@Test
Expand All @@ -428,7 +425,7 @@ public void shouldThrowExceptionIfPeriodHasNoSuggestedPeriod() {
when(periodReferenceDataService.searchByProgramAndFacility(programId, facilityId))
.thenReturn(Lists.newArrayList(currentPeriod));

when(periodReferenceDataService.searchById(suggestedPeriod.getId()))
when(periodService.getPeriod(suggestedPeriod.getId()))
.thenReturn(suggestedPeriod);

ProcessingPeriodDto period = periodService
Expand Down

0 comments on commit 133e86c

Please sign in to comment.