From 25fa0377df579fa64163474ca657fa59accc3cd0 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Mon, 8 Jun 2020 17:02:37 -0700 Subject: [PATCH] tidying --- .../uhn/fhir/jpa/bulk/api/IBulkDataExportSvc.java | 2 ++ .../jpa/bulk/BulkDataExportSvcImplR4Test.java | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/IBulkDataExportSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/IBulkDataExportSvc.java index bca2200b053..34a8c0d4017 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/IBulkDataExportSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/IBulkDataExportSvc.java @@ -80,6 +80,7 @@ public interface IBulkDataExportSvc { myFiles = new ArrayList<>(); } return myFiles; + } public BulkJobStatusEnum getStatus() { @@ -132,4 +133,5 @@ public interface IBulkDataExportSvc { } + } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java index 2a701e69b9d..a44e5c46d31 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java @@ -251,26 +251,29 @@ public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test { @Test - public void testBatchJob() throws InterruptedException { + public void testBatchJobSubmitsAndRuns() throws InterruptedException { createResources(); // Create a bulk job IBulkDataExportSvc.JobInfo jobDetails = myBulkDataExportSvc.submitJob(null, Sets.newHashSet("Patient", "Observation"), null, null); + //Add the UUID to the job JobParametersBuilder paramBuilder = new JobParametersBuilder().addString("jobUUID", jobDetails.getJobId()); 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) { - jobInfo = myBulkDataExportSvc.getJobInfoOrThrowResourceNotFound(jobDetails.getJobId()); + IBulkDataExportSvc.JobInfo jobInfo = myBulkDataExportSvc.getJobInfoOrThrowResourceNotFound(theJobId); if (jobInfo.getStatus() != BulkJobStatusEnum.COMPLETE) { Thread.sleep(1000L); - ourLog.warn("waiting.."); } else { - break; + return jobInfo; } } - assertThat(jobInfo.getStatus(), equalTo(BulkJobStatusEnum.COMPLETE)); } @Test