Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae committed Aug 26, 2024
1 parent ed7e2ec commit 9ef4b5e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ public Job preprocess(String jobUuid) {
return job;
}

if (job.getSince() != null && job.getUntil() != null
&& job.getUntil().toInstant().isBefore(job.getSince().toInstant())) {
log.warn("JobPreProcessorImpl > preprocess: job FAILED because the _until is before _since.");

eventLogger.logAndAlert(job.buildJobStatusChangeEvent(FAILED, EOB_JOB_FAILURE + " Job " + jobUuid
+ "failed because the _until is before _since."), PUBLIC_LIST);

job.setStatus(FAILED);
job.setStatusMessage("failed because the _until is before _since.");

jobRepository.save(job);
return job;
}

ContractDTO contract = contractWorkerClient.getContractByContractNumber(job.getContractNumber());
if (contract == null) {
throw new IllegalArgumentException("A job must always have a contract.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ void checkUntilAndR4Parameters() throws InterruptedException {
assertEquals(JobStatus.IN_PROGRESS, job.getStatus());
}

@Test
void checkUntilAndSinceParameters() {
when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job);
job.setFhirVersion(R4);
job.setSince(OffsetDateTime.of(2024, 7, 11, 1, 2, 3, 0, ZoneOffset.UTC));
job.setUntil(OffsetDateTime.of(2022, 7, 11, 1, 2, 3, 0, ZoneOffset.UTC));
job.setStatus(SUBMITTED);
cut.preprocess(job.getJobUuid());
assertEquals(JobStatus.FAILED, job.getStatus());
}

@Test
@DisplayName("Throws exception when the job for the given JobUuid is not in submitted status")
void whenTheJobForTheGivenJobUuidIsNotInSubmittedStatus_ThrowsException() {
Expand Down

0 comments on commit 9ef4b5e

Please sign in to comment.