fixing tests

This commit is contained in:
leif stawnyczy 2023-11-27 15:22:44 -05:00
parent 4c5800eb09
commit a87fde74dd
2 changed files with 11 additions and 6 deletions

View File

@ -8,6 +8,8 @@ import ca.uhn.fhir.batch2.model.JobInstanceStartRequest;
import ca.uhn.fhir.batch2.model.StatusEnum; import ca.uhn.fhir.batch2.model.StatusEnum;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse; import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse;
import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor;
import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.system.HapiSystemProperties;
@ -66,6 +68,8 @@ public class BulkImportCommandIT {
private IJobCoordinator myJobCoordinator; private IJobCoordinator myJobCoordinator;
private final BulkDataImportProvider myProvider = new BulkDataImportProvider(); private final BulkDataImportProvider myProvider = new BulkDataImportProvider();
private final FhirContext myCtx = FhirContext.forR4Cached(); private final FhirContext myCtx = FhirContext.forR4Cached();
@Mock
private IRequestPartitionHelperSvc myRequestPartitionHelperSvc;
@RegisterExtension @RegisterExtension
public RestfulServerExtension myRestfulServerExtension = new RestfulServerExtension(myCtx, myProvider) public RestfulServerExtension myRestfulServerExtension = new RestfulServerExtension(myCtx, myProvider)
.registerInterceptor(new LoggingInterceptor()); .registerInterceptor(new LoggingInterceptor());
@ -77,6 +81,7 @@ public class BulkImportCommandIT {
public void beforeEach() throws IOException { public void beforeEach() throws IOException {
myProvider.setFhirContext(myCtx); myProvider.setFhirContext(myCtx);
myProvider.setJobCoordinator(myJobCoordinator); myProvider.setJobCoordinator(myJobCoordinator);
myProvider.setRequestPartitionHelperService(myRequestPartitionHelperSvc);
myTempDir = Files.createTempDirectory("hapifhir"); myTempDir = Files.createTempDirectory("hapifhir");
ourLog.info("Created temp directory: {}", myTempDir); ourLog.info("Created temp directory: {}", myTempDir);
} }
@ -123,7 +128,7 @@ public class BulkImportCommandIT {
await().until(() -> myRestfulServerExtension.getRequestContentTypes().size(), equalTo(2)); await().until(() -> myRestfulServerExtension.getRequestContentTypes().size(), equalTo(2));
ourLog.info("Initiation requests complete"); ourLog.info("Initiation requests complete");
verify(myJobCoordinator, timeout(10000).times(1)).startInstance(myStartCaptor.capture()); verify(myJobCoordinator, timeout(10000).times(1)).startInstance(any(RequestDetails.class), myStartCaptor.capture());
JobInstanceStartRequest startRequest = myStartCaptor.getValue(); JobInstanceStartRequest startRequest = myStartCaptor.getValue();
BulkImportJobParameters jobParameters = startRequest.getParameters(BulkImportJobParameters.class); BulkImportJobParameters jobParameters = startRequest.getParameters(BulkImportJobParameters.class);
@ -165,7 +170,7 @@ public class BulkImportCommandIT {
await().until(() -> myRestfulServerExtension.getRequestContentTypes().size(), equalTo(2)); await().until(() -> myRestfulServerExtension.getRequestContentTypes().size(), equalTo(2));
ourLog.info("Initiation requests complete"); ourLog.info("Initiation requests complete");
verify(myJobCoordinator, timeout(10000).times(1)).startInstance(myStartCaptor.capture()); verify(myJobCoordinator, timeout(10000).times(1)).startInstance(any(RequestDetails.class), myStartCaptor.capture());
JobInstanceStartRequest startRequest = myStartCaptor.getValue(); JobInstanceStartRequest startRequest = myStartCaptor.getValue();
BulkImportJobParameters jobParameters = startRequest.getParameters(BulkImportJobParameters.class); BulkImportJobParameters jobParameters = startRequest.getParameters(BulkImportJobParameters.class);
@ -206,7 +211,7 @@ public class BulkImportCommandIT {
await().until(() -> myRestfulServerExtension.getRequestContentTypes().size(), equalTo(2)); await().until(() -> myRestfulServerExtension.getRequestContentTypes().size(), equalTo(2));
ourLog.info("Initiation requests complete"); ourLog.info("Initiation requests complete");
verify(myJobCoordinator, timeout(10000).times(1)).startInstance(myStartCaptor.capture()); verify(myJobCoordinator, timeout(10000).times(1)).startInstance(any(RequestDetails.class), myStartCaptor.capture());
try{ try{
JobInstanceStartRequest startRequest = myStartCaptor.getValue(); JobInstanceStartRequest startRequest = myStartCaptor.getValue();

View File

@ -76,13 +76,10 @@ public class BulkDataImportProvider {
public static final String PARAM_INPUT_TYPE = "type"; public static final String PARAM_INPUT_TYPE = "type";
private static final Logger ourLog = LoggerFactory.getLogger(BulkDataImportProvider.class); private static final Logger ourLog = LoggerFactory.getLogger(BulkDataImportProvider.class);
@Autowired
private IJobCoordinator myJobCoordinator; private IJobCoordinator myJobCoordinator;
@Autowired
private FhirContext myFhirCtx; private FhirContext myFhirCtx;
@Autowired
private IRequestPartitionHelperSvc myRequestPartitionHelperService; private IRequestPartitionHelperSvc myRequestPartitionHelperService;
private volatile List<String> myResourceTypeOrder; private volatile List<String> myResourceTypeOrder;
@ -94,14 +91,17 @@ public class BulkDataImportProvider {
super(); super();
} }
@Autowired
public void setJobCoordinator(IJobCoordinator theJobCoordinator) { public void setJobCoordinator(IJobCoordinator theJobCoordinator) {
myJobCoordinator = theJobCoordinator; myJobCoordinator = theJobCoordinator;
} }
@Autowired
public void setFhirContext(FhirContext theCtx) { public void setFhirContext(FhirContext theCtx) {
myFhirCtx = theCtx; myFhirCtx = theCtx;
} }
@Autowired
public void setRequestPartitionHelperService(IRequestPartitionHelperSvc theRequestPartitionHelperSvc) { public void setRequestPartitionHelperService(IRequestPartitionHelperSvc theRequestPartitionHelperSvc) {
myRequestPartitionHelperService = theRequestPartitionHelperSvc; myRequestPartitionHelperService = theRequestPartitionHelperSvc;
} }