mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 18:05:19 +00:00
Add test, add changelog, fix bug (#3494)
* Add test, add changelog, fix bug * Test fix * Fix some more test artifacts
This commit is contained in:
parent
5b413a9135
commit
b1e2d7c104
@ -1249,8 +1249,8 @@ class ParserState<T> {
|
|||||||
public void wereBack() {
|
public void wereBack() {
|
||||||
super.wereBack();
|
super.wereBack();
|
||||||
|
|
||||||
if (getCurrentElement() instanceof IDomainResource) {
|
if (getCurrentElement() instanceof IBaseResource) {
|
||||||
IDomainResource elem = (IDomainResource) getCurrentElement();
|
IBaseResource elem = (IBaseResource) getCurrentElement();
|
||||||
String resourceName = myContext.getResourceType(elem);
|
String resourceName = myContext.getResourceType(elem);
|
||||||
String versionId = elem.getMeta().getVersionId();
|
String versionId = elem.getMeta().getVersionId();
|
||||||
if (StringUtils.isBlank(elem.getIdElement().getIdPart())) {
|
if (StringUtils.isBlank(elem.getIdElement().getIdPart())) {
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 3493
|
||||||
|
title: "Previously the Fhir parser would only set the resource type on the resource ID for resources which implemented `IDomainResource`. This caused a few resource types
|
||||||
|
to be missed. This has been corrected, and resource type is now set on the id element for all `IBaseResource` instances instead."
|
@ -791,7 +791,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||||||
org.hl7.fhir.dstu3.model.Bundle responseBundle = (org.hl7.fhir.dstu3.model.Bundle) outParams.getParameter().get(0).getResource();
|
org.hl7.fhir.dstu3.model.Bundle responseBundle = (org.hl7.fhir.dstu3.model.Bundle) outParams.getParameter().get(0).getResource();
|
||||||
|
|
||||||
// Print the response bundle
|
// Print the response bundle
|
||||||
assertEquals("8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19", responseBundle.getId());
|
assertEquals("Bundle/8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19", responseBundle.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -561,7 +561,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
|
|||||||
});
|
});
|
||||||
|
|
||||||
Bundle response = myClient.search().forResource(Patient.class).count(1).returnBundle(Bundle.class).execute();
|
Bundle response = myClient.search().forResource(Patient.class).count(1).returnBundle(Bundle.class).execute();
|
||||||
String searchId = response.getId();
|
String searchId = response.getIdElement().getIdPart();
|
||||||
|
|
||||||
// 2 results returned, but no total since it's stripped
|
// 2 results returned, but no total since it's stripped
|
||||||
assertEquals(1, response.getEntry().size());
|
assertEquals(1, response.getEntry().size());
|
||||||
@ -616,7 +616,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
|
|||||||
myClient.create().resource(new Patient().setGender(Enumerations.AdministrativeGender.FEMALE).addName(new HumanName().setFamily("3"))).execute();
|
myClient.create().resource(new Patient().setGender(Enumerations.AdministrativeGender.FEMALE).addName(new HumanName().setFamily("3"))).execute();
|
||||||
|
|
||||||
Bundle response = myClient.search().forResource(Patient.class).count(1).returnBundle(Bundle.class).execute();
|
Bundle response = myClient.search().forResource(Patient.class).count(1).returnBundle(Bundle.class).execute();
|
||||||
String searchId = response.getId();
|
String searchId = response.getIdElement().getIdPart();
|
||||||
|
|
||||||
assertEquals(1, response.getEntry().size());
|
assertEquals(1, response.getEntry().size());
|
||||||
assertNull(response.getTotalElement().getValue());
|
assertNull(response.getTotalElement().getValue());
|
||||||
|
@ -13,6 +13,7 @@ import com.google.common.collect.Sets;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.io.output.NullWriter;
|
import org.apache.commons.io.output.NullWriter;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.r4.model.AuditEvent;
|
import org.hl7.fhir.r4.model.AuditEvent;
|
||||||
import org.hl7.fhir.r4.model.Basic;
|
import org.hl7.fhir.r4.model.Basic;
|
||||||
import org.hl7.fhir.r4.model.Binary;
|
import org.hl7.fhir.r4.model.Binary;
|
||||||
@ -59,6 +60,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.hamcrest.core.IsNot.not;
|
import static org.hamcrest.core.IsNot.not;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -87,6 +91,27 @@ public class JsonParserR4Test extends BaseTest {
|
|||||||
ourCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(true);
|
ourCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNonDomainResourcesHaveIdResourceTypeParsed() {
|
||||||
|
//Test a non-domain resource
|
||||||
|
String binaryPayload = "{\n" +
|
||||||
|
" \"resourceType\": \"Binary\",\n" +
|
||||||
|
" \"id\": \"b123\"\n" +
|
||||||
|
"}\n";
|
||||||
|
IBaseResource iBaseResource = ourCtx.newJsonParser().parseResource(binaryPayload);
|
||||||
|
String resourceType = iBaseResource.getIdElement().getResourceType();
|
||||||
|
assertThat(resourceType, is(equalTo("Binary")));
|
||||||
|
|
||||||
|
//Test a domain resource.
|
||||||
|
String observationPayload = "{\n" +
|
||||||
|
" \"resourceType\": \"Observation\",\n" +
|
||||||
|
" \"id\": \"o123\"\n" +
|
||||||
|
"}\n";
|
||||||
|
IBaseResource obs = ourCtx.newJsonParser().parseResource(observationPayload);
|
||||||
|
resourceType = obs.getIdElement().getResourceType();
|
||||||
|
assertThat(resourceType, is(equalTo("Observation")));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntitiesNotConverted() throws IOException {
|
public void testEntitiesNotConverted() throws IOException {
|
||||||
Device input = loadResource(ourCtx, Device.class, "/entities-from-cerner.json");
|
Device input = loadResource(ourCtx, Device.class, "/entities-from-cerner.json");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user