Class MockContentPolicyStorage

java.lang.Object
io.wcm.testing.mock.aem.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 Summary

    Modifier and Type
    Method
    Description
    static @Nullable com.day.cq.wcm.api.policies.ContentPolicyMapping
    getContentPolicyMapping(@NotNull 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 String resourceType, @NotNull Map<String,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 Details

    • 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