Fix tests
This commit is contained in:
parent
a9cb4dae2f
commit
7f87def432
|
@ -188,6 +188,7 @@ public class DaoConfig {
|
||||||
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
|
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
|
||||||
*/
|
*/
|
||||||
public void setBundleTypesAllowedForStorage(Set<String> theBundleTypesAllowedForStorage) {
|
public void setBundleTypesAllowedForStorage(Set<String> theBundleTypesAllowedForStorage) {
|
||||||
|
Validate.notNull(theBundleTypesAllowedForStorage, "theBundleTypesAllowedForStorage must not be null");
|
||||||
myBundleTypesAllowedForStorage = theBundleTypesAllowedForStorage;
|
myBundleTypesAllowedForStorage = theBundleTypesAllowedForStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3<Bundle> {
|
||||||
super.preProcessResourceForStorage(theResource);
|
super.preProcessResourceForStorage(theResource);
|
||||||
|
|
||||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
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)");
|
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);
|
throw new UnprocessableEntityException(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class FhirResourceDaoBundleR4 extends FhirResourceDaoR4<Bundle> {
|
||||||
super.preProcessResourceForStorage(theResource);
|
super.preProcessResourceForStorage(theResource);
|
||||||
|
|
||||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
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)");
|
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);
|
throw new UnprocessableEntityException(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||||
myBundleDao.create(bundle, mySrd);
|
myBundleDao.create(bundle, mySrd);
|
||||||
fail();
|
fail();
|
||||||
} catch (UnprocessableEntityException e) {
|
} 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();
|
bundle = new Bundle();
|
||||||
|
@ -329,7 +329,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||||
myBundleDao.create(bundle, mySrd);
|
myBundleDao.create(bundle, mySrd);
|
||||||
fail();
|
fail();
|
||||||
} catch (UnprocessableEntityException e) {
|
} 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();
|
bundle = new Bundle();
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
client.create().resource(resBody).execute().getId();
|
client.create().resource(resBody).execute().getId();
|
||||||
fail();
|
fail();
|
||||||
} catch (UnprocessableEntityException e) {
|
} 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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue