Fix tests

This commit is contained in:
James Agnew 2018-06-01 07:40:33 -04:00
parent a9cb4dae2f
commit 7f87def432
5 changed files with 6 additions and 5 deletions

View File

@ -188,6 +188,7 @@ public class DaoConfig {
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
*/
public void setBundleTypesAllowedForStorage(Set<String> theBundleTypesAllowedForStorage) {
Validate.notNull(theBundleTypesAllowedForStorage, "theBundleTypesAllowedForStorage must not be null");
myBundleTypesAllowedForStorage = theBundleTypesAllowedForStorage;
}

View File

@ -36,7 +36,7 @@ public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3<Bundle> {
super.preProcessResourceForStorage(theResource);
Set<String> 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);
}

View File

@ -37,7 +37,7 @@ public class FhirResourceDaoBundleR4 extends FhirResourceDaoR4<Bundle> {
super.preProcessResourceForStorage(theResource);
Set<String> 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);
}

View File

@ -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();

View File

@ -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"));
}
}