Skip to content

Commit

Permalink
issues #2281 and #864 - batch/transaction bundle processing changes
Browse files Browse the repository at this point in the history
1. FHIRRestHelper.validateBundle now returns a sparse array (modeled as
a map) of bundle response entries with warnings. It used to construct an
entire response bundle.

2. FHIRRestHelper.processEntriesByMethod replaces
FHIRRestHelper.processEntriesForMethod and iterates the request entries
a single time, instead of once-per-method.

3. Entries are collected into an array instead of "modifying" the
responseBundle with each one (which forced lots of needless copying
since our model is now immutable).

4. Stop duplicating custom operation results in the
`Bundle.entry.response.outcome` field of the response. We already copy
the operation's result in the `Bundle.entry.resource` and that should be
sufficient.

I also made significant formatting changes in FHIRRestHelper.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
  • Loading branch information
lmsurpre committed Apr 24, 2021
1 parent 8507138 commit 3be6f80
Show file tree
Hide file tree
Showing 4 changed files with 350 additions and 407 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package com.ibm.fhir.server.test;

import static com.ibm.fhir.model.test.TestUtil.isResourceInResponse;

import static com.ibm.fhir.model.type.String.string;
import static org.testng.Assert.assertNotNull;
import static org.testng.AssertJUnit.assertEquals;
Expand Down Expand Up @@ -2242,17 +2241,7 @@ public void testBatchCustomOperations() throws Exception {

Bundle bundle = buildBundle(BundleType.BATCH);

// Commented out because $hello operation isn't installed by default
// 1. GET request at global level
//bundle = addRequestToBundle(null, bundle, HTTPVerb.GET, "$hello?input=" + message, null, null);

// 2. POST request at global level
//Parameters hellowWorldParameters = Parameters.builder()
// .parameter(Parameter.builder().name(string("input")).value(string(message)).build()).build();

//bundle = addRequestToBundle(null, bundle, HTTPVerb.POST, "$hello", null, hellowWorldParameters);

// 3. POST request with resource at resource level
// 1. POST request with resource at resource level
Patient patient = TestUtil.readLocalResource("Patient_JohnDoe.json");

Parameters validateOperationParameters = Parameters.builder()
Expand All @@ -2261,10 +2250,21 @@ public void testBatchCustomOperations() throws Exception {
bundle = addRequestToBundle(null, bundle, HTTPVerb.POST, "Patient/$validate", null,
validateOperationParameters);

// 4. POST request with resource at resource instance level
// 2. POST request with resource at resource instance level
bundle = addRequestToBundle(null, bundle, HTTPVerb.POST,
"Patient/" + patientB1.getId() + "/$validate", null, validateOperationParameters);

//////
// Commented out because $hello operation isn't installed by default
//////
// 3. GET request at global level
//bundle = addRequestToBundle(null, bundle, HTTPVerb.GET, "$hello?input=" + message, null, null);

// 4. POST request at global level
//Parameters hellowWorldParameters = Parameters.builder()
// .parameter(Parameter.builder().name(string("input")).value(string(message)).build()).build();
//bundle = addRequestToBundle(null, bundle, HTTPVerb.POST, "$hello", null, hellowWorldParameters);

printBundle(method, "request", bundle);

Entity<Bundle> entity = Entity.entity(bundle, FHIRMediaType.APPLICATION_FHIR_JSON);
Expand All @@ -2273,17 +2273,11 @@ public void testBatchCustomOperations() throws Exception {
Bundle responseBundle = getEntityWithExtraWork(response,method);

assertResponseBundle(responseBundle, BundleType.BATCH_RESPONSE, 2);
// Commented out because $hello operation isn't installed by default
// assertGoodGetResponse(responseBundle.getEntry().get(0), Status.OK.getStatusCode());
// assertGoodGetResponse(responseBundle.getEntry().get(1), Status.OK.getStatusCode());
assertGoodGetResponse(responseBundle.getEntry().get(0), Status.OK.getStatusCode());
assertGoodGetResponse(responseBundle.getEntry().get(1), Status.OK.getStatusCode());

// Commented out because $hello operation isn't installed by default
// assertNotNull(responseBundle.getEntry().get(0).getResource().getParameters());
// assertNotNull(responseBundle.getEntry().get(1).getResource().getParameters());
assertNotNull(responseBundle.getEntry().get(0).getResponse().getOutcome());
assertNotNull(responseBundle.getEntry().get(1).getResponse().getOutcome());
assertNotNull(responseBundle.getEntry().get(0).getResource());
assertNotNull(responseBundle.getEntry().get(1).getResource());
}

@Test(groups = { "transaction" })
Expand Down
Loading

0 comments on commit 3be6f80

Please sign in to comment.