diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/BundleUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/BundleUtil.java index 54395f90bf7..d199fec7faa 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/BundleUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/BundleUtil.java @@ -249,7 +249,7 @@ public class BundleUtil { public static boolean isStandaloneBundleResource(FhirContext theContext, IBaseBundle theBundle) { BundleTypeEnum bundleType = BundleUtil.getBundleTypeEnum(theContext, theBundle); - return bundleType != null && STANDALONE_BUNDLE_RESOURCE_TYPES.contains(bundleType); + return bundleType != null && isStandaloneBundleType(bundleType); } public static boolean isStandaloneBundleType(BundleTypeEnum theBundleType) { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java index bbce8f3b32f..06238efbd80 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java @@ -1672,10 +1672,11 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes @ArgumentsSource(StandaloneBundleTypesArgumentsProvider.class) public void testPermissionsToPostTransaction_withStandaloneBundles_successfullyPostsTransactions(BundleTypeEnum theStandaloneBundleType){ Bundle nestedBundle = new Bundle(); + nestedBundle.setId("some-bundle"); BundleUtil.setBundleType(myFhirContext, nestedBundle, theStandaloneBundleType.getCode()); BundleBuilder builder = new BundleBuilder(myFhirContext); - builder.addTransactionCreateEntry(nestedBundle); + builder.addTransactionUpdateEntry(nestedBundle); IBaseBundle transaction = builder.getBundle(); myServer.getRestfulServer().registerInterceptor(myWriteResourcesInTransactionAuthorizationInterceptor); @@ -1690,7 +1691,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes Bundle savedNestedBundle = (Bundle) savedBundles.get(0); assertEquals(theStandaloneBundleType, BundleUtil.getBundleTypeEnum(myFhirContext, savedNestedBundle)); - assertTrue(savedNestedBundle.getEntry().isEmpty()); + assertEquals(nestedBundle.getIdPart(), savedNestedBundle.getIdPart()); } @ParameterizedTest @@ -1723,9 +1724,9 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes @ArgumentsSource(StandaloneBundleTypesArgumentsProvider.class) public void testPermissionsToPostTransactions_withStandaloneBundles_onlyProcessesTransactionsOneLevelDeep(BundleTypeEnum theStandaloneBundleType){ // second level transaction - BundleBuilder builder = new BundleBuilder(myFhirContext); Patient patient = new Patient(); - patient.setBirthDate(Date.valueOf("2000-01-01")); + patient.setId("some-patient"); + BundleBuilder builder = new BundleBuilder(myFhirContext); builder.addTransactionCreateEntry(patient); IBaseBundle secondLevelTransaction = builder.getBundle(); @@ -1763,7 +1764,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes assertEquals(Bundle.BundleType.TRANSACTION, savedSecondLevelTransaction.getType()); assertEquals(1, savedSecondLevelTransaction.getEntry().size()); Patient patientSavedInsideBundle = (Patient) savedSecondLevelTransaction.getEntry().get(0).getResource(); - assertEquals(patient.getBirthDate(), patientSavedInsideBundle.getBirthDate()); + assertEquals(patient.getIdPart(), patientSavedInsideBundle.getIdPart()); // verify second level Patient transaction did NOT execute assertTrue(myPatientDao.search(SearchParameterMap.newSynchronous(), mySrd).isEmpty()); @@ -1900,7 +1901,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes Set arguments = new HashSet<>(); Arrays.stream(BundleTypeEnum.values()) - .filter(type -> BundleUtil.isStandaloneBundleType(type)) + .filter(BundleUtil::isStandaloneBundleType) .forEach(type -> arguments.add(Arguments.of(type))); return arguments.stream();