Class MockContentPolicyStorage


  • public final class MockContentPolicyStorage
    extends Object
    Implements a very simplified storage concept for storing and resolving content policies and their mappings. Basically it stores one global content policy per resource type, and one mapping for it. This is usually enough for unit tests.
    • Method Detail

      • storeContentPolicyMapping

        @NotNull
        public static @NotNull com.day.cq.wcm.api.policies.ContentPolicyMapping storeContentPolicyMapping​(@NotNull
                                                                                                          @NotNull String resourceType,
                                                                                                          @NotNull
                                                                                                          @NotNull Map<String,​Object> properties,
                                                                                                          @NotNull
                                                                                                          @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Creates a mocked content policy with the given properties and maps it to all content resources with the given resource type. This is a shortcut to easily test your components with a content policy.
        Parameters:
        resourceType - Resource type that should be mapped to the content policy
        properties - Properties for the content policy
        resourceResolver - Resource resolver
        Returns:
        New content policy mapping
      • getContentPolicyMapping

        @Nullable
        public static @Nullable com.day.cq.wcm.api.policies.ContentPolicyMapping getContentPolicyMapping​(@NotNull
                                                                                                         @NotNull String resourceType,
                                                                                                         @NotNull
                                                                                                         @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Get content policy mapping that was stored for the given resource type.
        Parameters:
        resourceType - Resource type
        resourceResolver - Resource resolver
        Returns:
        Content policy mapping or null if none found