Package io.wcm.testing.mock.aem
Class MockContentPolicyStorage
java.lang.Object
io.wcm.testing.mock.aem.MockContentPolicyStorage
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 TypeMethodDescriptionstatic @Nullable com.day.cq.wcm.api.policies.ContentPolicyMappinggetContentPolicyMapping(@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.ContentPolicyMappingstoreContentPolicyMapping(@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.
-
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 policyproperties- Properties for the content policyresourceResolver- 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 typeresourceResolver- Resource resolver- Returns:
- Content policy mapping or null if none found
-