Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
James Agnew 2020-01-03 13:43:11 -05:00
commit 82921472d4
3 changed files with 35 additions and 1 deletions

View File

@ -375,6 +375,10 @@ public abstract class BaseClient implements IRestfulClient {
}
}
if (inputStreamToReturn == null) {
inputStreamToReturn = new ByteArrayInputStream(new byte[]{});
}
return binding.invokeClient(mimeType, inputStreamToReturn, response.getStatus(), headers);
}

View File

@ -79,7 +79,7 @@ However, if you have needs beyond simply validating against the core FHIR specif
{{snippet:classpath:/ca/uhn/hapi/fhir/docs/ValidatorExamples.java|validateSupplyProfiles}}
```
# Buiilt-In Validation Support Classes
# Built-In Validation Support Classes
There are a several implementations of the [IValidationSupport](/hapi-fhir/apidocs/hapi-fhir-structures-r4/org/hl7/fhir/r4/hapi/ctx/IValidationSupport.html) interface built into HAPI FHIR that can be used, typically in a chain.

View File

@ -14,6 +14,8 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
import ca.uhn.fhir.model.dstu2.resource.Conformance.Rest;
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestSecurity;
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
import ca.uhn.fhir.model.primitive.*;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.IParser;
@ -22,6 +24,7 @@ import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory;
import ca.uhn.fhir.rest.client.api.*;
import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException;
import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException;
import ca.uhn.fhir.rest.client.impl.BaseClient;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.param.DateParam;
@ -2360,6 +2363,33 @@ public class GenericClientDstu2Test {
assertEquals("Patient/2/_history/2", response.getEntry().get(1).getResponse().getLocation());
}
@Test
public void testTransactionHandle204NoBody() throws Exception {
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = new Bundle();
bundle.setType(BundleTypeEnum.TRANSACTION);
ca.uhn.fhir.model.dstu2.resource.Bundle.Entry entry = bundle.addEntry();
entry.setResource(new Patient());
entry.getRequest().setMethod(HTTPVerbEnum.PUT);
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), Constants.STATUS_HTTP_204_NO_CONTENT, ""));
when(myHttpResponse.getEntity() ).thenReturn(null);
try {
client.transaction().withBundle(bundle).execute();
fail("Should throw an exception");
} catch (NonFhirResponseException e) {
assertEquals("status", Constants.STATUS_HTTP_204_NO_CONTENT, e.getStatusCode());
}
}
@Test
public void testUpdateConditional() throws Exception {
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);