From 7f87def432ec174041169579191ac359490a8aff Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 1 Jun 2018 07:40:33 -0400 Subject: [PATCH] Fix tests --- .../src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java | 1 + .../ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java | 2 +- .../java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoBundleR4.java | 2 +- .../ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java | 4 ++-- .../ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java index b8c5f38f313..bd49b51fdd0 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java @@ -188,6 +188,7 @@ public class DaoConfig { * @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE */ public void setBundleTypesAllowedForStorage(Set theBundleTypesAllowedForStorage) { + Validate.notNull(theBundleTypesAllowedForStorage, "theBundleTypesAllowedForStorage must not be null"); myBundleTypesAllowedForStorage = theBundleTypesAllowedForStorage; } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java index 317778c9b71..752836baddc 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java @@ -36,7 +36,7 @@ public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3 { super.preProcessResourceForStorage(theResource); Set allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage(); - if (!allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) { + if (theResource.getType() == null || !allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) { String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)"); throw new UnprocessableEntityException(message); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoBundleR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoBundleR4.java index bc247a88605..0aaa99f2685 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoBundleR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoBundleR4.java @@ -37,7 +37,7 @@ public class FhirResourceDaoBundleR4 extends FhirResourceDaoR4 { super.preProcessResourceForStorage(theResource); Set allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage(); - if (!allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) { + if (theResource.getType() == null || !allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) { String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)"); throw new UnprocessableEntityException(message); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java index 79539d19f88..7d9e6df1f57 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java @@ -319,7 +319,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { myBundleDao.create(bundle, mySrd); fail(); } catch (UnprocessableEntityException e) { - assertEquals("Unable to store a Bundle resource on this server with a Bundle.type of: (missing)", e.getMessage()); + assertEquals("Unable to store a Bundle resource on this server with a Bundle.type value of: (missing)", e.getMessage()); } bundle = new Bundle(); @@ -329,7 +329,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { myBundleDao.create(bundle, mySrd); fail(); } catch (UnprocessableEntityException e) { - assertEquals("Unable to store a Bundle resource on this server with a Bundle.type of: batch-response", e.getMessage()); + assertEquals("Unable to store a Bundle resource on this server with a Bundle.type value of: batch-response", e.getMessage()); } bundle = new Bundle(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java index 13dbedd304f..289f63e8f3e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java @@ -135,7 +135,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { client.create().resource(resBody).execute().getId(); fail(); } catch (UnprocessableEntityException e) { - assertThat(e.getMessage(), containsString("Unable to store a Bundle resource on this server with a Bundle.type of: transaction")); + assertThat(e.getMessage(), containsString("Unable to store a Bundle resource on this server with a Bundle.type value of: transaction")); } }