Search in sources :

Example 1 with SlingModelFilter

use of com.adobe.cq.export.json.SlingModelFilter in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ContainerImplTest method setUp.

@BeforeEach
public void setUp() {
    context.load().json(TEST_BASE + CoreComponentTestContext.TEST_CONTENT_JSON, CONTAINING_PAGE);
    context.registerService(FormStructureHelperFactory.class, resource -> formStructureHelper);
    context.registerService(SlingModelFilter.class, new SlingModelFilter() {

        private final Set<String> IGNORED_NODE_NAMES = new HashSet<String>() {

            {
                add(NameConstants.NN_RESPONSIVE_CONFIG);
                add(MSMNameConstants.NT_LIVE_SYNC_CONFIG);
                add("cq:annotations");
            }
        };

        @Override
        public Map<String, Object> filterProperties(Map<String, Object> map) {
            return map;
        }

        @Override
        public Iterable<Resource> filterChildResources(Iterable<Resource> childResources) {
            return StreamSupport.stream(childResources.spliterator(), false).filter(r -> !IGNORED_NODE_NAMES.contains(r.getName())).collect(Collectors.toList());
        }
    });
    context.registerAdapter(MockSlingHttpServletRequest.class, LinkHandler.class, new LinkHandler());
    FormsHelperStubber.createStub();
}
Also used : SlingModelFilter(com.adobe.cq.export.json.SlingModelFilter) Resource(org.apache.sling.api.resource.Resource) Map(java.util.Map) LinkHandler(com.adobe.cq.wcm.core.components.internal.link.LinkHandler) HashSet(java.util.HashSet) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SlingModelFilter (com.adobe.cq.export.json.SlingModelFilter)1 LinkHandler (com.adobe.cq.wcm.core.components.internal.link.LinkHandler)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Resource (org.apache.sling.api.resource.Resource)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1