Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bennavapbc committed Nov 19, 2024
1 parent ae49bd9 commit 6073972
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,15 @@ public int numberOfBeneficiariesToProcess(Job job, ContractDTO contract) {
@Trace(metricName = "EnrollmentLoadFromDB", dispatcher = true)
@Override
public CoveragePagingResult pageCoverage(Job job, ContractDTO contract) {
ZonedDateTime now = getEndDateTime();

if (contract == null) {
throw new CoverageDriverException("cannot retrieve metadata for job missing contract");
}

ZonedDateTime startDateTime = getStartDateTime(contract);
Optional<String> additionalDetails = Optional.empty();
try {
ZonedDateTime now = getEndDateTime();
ZonedDateTime startDateTime = getStartDateTime(contract);
// Check that all coverage periods necessary are present before beginning to page
while (startDateTime.isBefore(now)) {
additionalDetails = Optional.of(String.format("contract='%s' month='%s', year='%s'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void pageRequestWhenSinceDateAfterNow() {

@DisplayName("Paging coverage fails when coverage periods are missing")
@Test
void failPagingWhenCoveragePeriodMissing() {
void failPagingWhenCoveragePeriodMissing(CapturedOutput output) {

when(coverageService.getCoveragePeriod(any(), anyInt(), anyInt())).thenThrow(new EntityNotFoundException());

Expand All @@ -243,6 +243,8 @@ void failPagingWhenCoveragePeriodMissing() {

CoverageDriverException startDateInFuture = assertThrows(CoverageDriverException.class, () -> driver.pageCoverage(job, contract));
assertEquals(EntityNotFoundException.class, startDateInFuture.getCause().getClass());
assertTrue(output.getOut().contains("coverage period missing or year,month query incorrect, driver should have resolved earlier - contract='null' month='1', year='2020'"));

}

@DisplayName("Paging coverage periods")
Expand Down

0 comments on commit 6073972

Please sign in to comment.