Search in sources :

Example 1 with AemContext

use of io.wcm.testing.mock.aem.junit.AemContext in project acs-aem-commons by Adobe-Consulting-Services.

the class SyntheticWorkflowSessionTest method setUp.

@Before
public void setUp() throws Exception {
    context = new AemContext(ResourceResolverType.JCR_MOCK);
    ResourceResolver resourceResolver = context.resourceResolver();
    session = SyntheticWorkflowSession.createSyntheticWorkflowSession(new SyntheticWorkflowRunnerImpl(), resourceResolver.adaptTo(Session.class));
    SyntheticWorkflowData workflowData = new SyntheticWorkflowData("JCR_PATH", "/content/test");
    workflowData.getMetaDataMap().put("cat", "meow");
    workflowData.getMetaDataMap().put("bird", "ka-kaw");
    syntheticWorkflow = new SyntheticWorkflow("test", workflowData);
}
Also used : SyntheticWorkflowData(com.adobe.acs.commons.workflow.synthetic.impl.SyntheticWorkflowData) AemContext(io.wcm.testing.mock.aem.junit.AemContext) SyntheticWorkflowRunnerImpl(com.adobe.acs.commons.workflow.synthetic.impl.SyntheticWorkflowRunnerImpl) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Before(org.junit.Before)

Example 2 with AemContext

use of io.wcm.testing.mock.aem.junit.AemContext in project aem-core-cif-components by adobe.

the class TestContext method buildAemContextInternal.

private static AemContextBuilder buildAemContextInternal() {
    return new AemContextBuilder().resourceResolverType(ResourceResolverType.JCR_MOCK).<AemContext>afterSetUp(context -> {
        // register commonly required ootb services
        context.registerService(PageManagerFactory.class, rr -> context.pageManager());
        XSSAPI xssApi = mock(XSSAPI.class);
        when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class));
        context.registerService(XSSAPI.class, xssApi);
    });
}
Also used : XSSAPI(org.apache.sling.xss.XSSAPI) AemContext(io.wcm.testing.mock.aem.junit.AemContext) AemContextBuilder(io.wcm.testing.mock.aem.junit.AemContextBuilder)

Example 3 with AemContext

use of io.wcm.testing.mock.aem.junit.AemContext in project acs-aem-commons by Adobe-Consulting-Services.

the class SynthesizedSlingHttpServletRequestTest method setUp.

@Before
public void setUp() throws Exception {
    context = new AemContext(ResourceResolverType.JCR_MOCK);
    resourceResolver = context.resourceResolver();
    synthesizedSlingHttpServletRequest = new SynthesizedSlingHttpServletRequest(context.request());
}
Also used : AemContext(io.wcm.testing.mock.aem.junit.AemContext) Before(org.junit.Before)

Example 4 with AemContext

use of io.wcm.testing.mock.aem.junit.AemContext in project acs-aem-commons by Adobe-Consulting-Services.

the class RequestPathInfoWrapperTest method setUp.

@Before
public void setUp() throws Exception {
    context = new AemContext(ResourceResolverType.JCR_OAK);
    context.load().json(getClass().getResourceAsStream("RequestPathInfoWrapperContent.json"), TEST_PATH);
    resourceResolver = context.resourceResolver();
    requestPathInfoWrapper = RequestPathInfoWrapper.createRequestPathInfoWrapper(context.requestPathInfo(), resourceResolver.getResource(TEST_PATH));
}
Also used : AemContext(io.wcm.testing.mock.aem.junit.AemContext) Before(org.junit.Before)

Example 5 with AemContext

use of io.wcm.testing.mock.aem.junit.AemContext in project aem-core-cif-components by adobe.

the class TestContext method buildAemContextInternal.

private static AemContextBuilder buildAemContextInternal() {
    return new AemContextBuilder().resourceResolverType(ResourceResolverType.JCR_MOCK).<AemContext>afterSetUp(context -> {
        // register commonly required ootb services
        context.registerService(PageManagerFactory.class, rr -> context.pageManager());
        context.registerService(Externalizer.class, new MockExternalizer());
        context.registerInjectActivateService(new DefaultPathProcessor());
        XSSAPI xssApi = mock(XSSAPI.class);
        when(xssApi.filterHTML(Mockito.anyString())).then(i -> i.getArgumentAt(0, String.class));
        context.registerService(XSSAPI.class, xssApi);
        // register commonly used cif services
        context.registerInjectActivateService(new SpecificPageStrategy());
        context.registerInjectActivateService(new UrlProviderImpl());
    });
}
Also used : XSSAPI(org.apache.sling.xss.XSSAPI) UrlProviderImpl(com.adobe.cq.commerce.core.components.internal.services.UrlProviderImpl) AemContext(io.wcm.testing.mock.aem.junit.AemContext) SpecificPageStrategy(com.adobe.cq.commerce.core.components.internal.services.SpecificPageStrategy) AemContextBuilder(io.wcm.testing.mock.aem.junit.AemContextBuilder) DefaultPathProcessor(com.adobe.cq.wcm.core.components.internal.link.DefaultPathProcessor)

Aggregations

AemContext (io.wcm.testing.mock.aem.junit.AemContext)5 Before (org.junit.Before)3 AemContextBuilder (io.wcm.testing.mock.aem.junit.AemContextBuilder)2 XSSAPI (org.apache.sling.xss.XSSAPI)2 SyntheticWorkflowData (com.adobe.acs.commons.workflow.synthetic.impl.SyntheticWorkflowData)1 SyntheticWorkflowRunnerImpl (com.adobe.acs.commons.workflow.synthetic.impl.SyntheticWorkflowRunnerImpl)1 SpecificPageStrategy (com.adobe.cq.commerce.core.components.internal.services.SpecificPageStrategy)1 UrlProviderImpl (com.adobe.cq.commerce.core.components.internal.services.UrlProviderImpl)1 DefaultPathProcessor (com.adobe.cq.wcm.core.components.internal.link.DefaultPathProcessor)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1