This commit is contained in:
Tadgh 2020-06-08 17:02:37 -07:00
parent 864c9c2cb8
commit 25fa0377df
2 changed files with 11 additions and 6 deletions

View File

@ -80,6 +80,7 @@ public interface IBulkDataExportSvc {
myFiles = new ArrayList<>(); myFiles = new ArrayList<>();
} }
return myFiles; return myFiles;
} }
public BulkJobStatusEnum getStatus() { public BulkJobStatusEnum getStatus() {
@ -132,4 +133,5 @@ public interface IBulkDataExportSvc {
} }
} }

View File

@ -251,26 +251,29 @@ public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test {
@Test @Test
public void testBatchJob() throws InterruptedException { public void testBatchJobSubmitsAndRuns() throws InterruptedException {
createResources(); createResources();
// Create a bulk job // Create a bulk job
IBulkDataExportSvc.JobInfo jobDetails = myBulkDataExportSvc.submitJob(null, Sets.newHashSet("Patient", "Observation"), null, null); IBulkDataExportSvc.JobInfo jobDetails = myBulkDataExportSvc.submitJob(null, Sets.newHashSet("Patient", "Observation"), null, null);
//Add the UUID to the job //Add the UUID to the job
JobParametersBuilder paramBuilder = new JobParametersBuilder().addString("jobUUID", jobDetails.getJobId()); JobParametersBuilder paramBuilder = new JobParametersBuilder().addString("jobUUID", jobDetails.getJobId());
myBatchJobSubmitter.runJob(myBulkJob, paramBuilder.toJobParameters()); myBatchJobSubmitter.runJob(myBulkJob, paramBuilder.toJobParameters());
IBulkDataExportSvc.JobInfo jobInfo; IBulkDataExportSvc.JobInfo jobInfo = awaitJobCompletion(jobDetails.getJobId());
assertThat(jobInfo.getStatus(), equalTo(BulkJobStatusEnum.COMPLETE));
}
public IBulkDataExportSvc.JobInfo awaitJobCompletion(String theJobId) throws InterruptedException {
while(true) { while(true) {
jobInfo = myBulkDataExportSvc.getJobInfoOrThrowResourceNotFound(jobDetails.getJobId()); IBulkDataExportSvc.JobInfo jobInfo = myBulkDataExportSvc.getJobInfoOrThrowResourceNotFound(theJobId);
if (jobInfo.getStatus() != BulkJobStatusEnum.COMPLETE) { if (jobInfo.getStatus() != BulkJobStatusEnum.COMPLETE) {
Thread.sleep(1000L); Thread.sleep(1000L);
ourLog.warn("waiting..");
} else { } else {
break; return jobInfo;
} }
} }
assertThat(jobInfo.getStatus(), equalTo(BulkJobStatusEnum.COMPLETE));
} }
@Test @Test