Class MockContentPolicyStorage


  • public final class MockContentPolicyStorage
    extends java.lang.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 Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @Nullable com.day.cq.wcm.api.policies.ContentPolicyMapping getContentPolicyMapping​(@NotNull java.lang.String resourceType, @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Get content policy mapping that was stored for the given resource type.
      static @NotNull com.day.cq.wcm.api.policies.ContentPolicyMapping storeContentPolicyMapping​(@NotNull java.lang.String resourceType, @NotNull java.util.Map<java.lang.String,​java.lang.Object> properties, @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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • storeContentPolicyMapping

        @NotNull
        public static @NotNull com.day.cq.wcm.api.policies.ContentPolicyMapping storeContentPolicyMapping​(@NotNull
                                                                                                          @NotNull java.lang.String resourceType,
                                                                                                          @NotNull
                                                                                                          @NotNull java.util.Map<java.lang.String,​java.lang.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 java.lang.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