use of io.wcm.testing.mock.aem.junit5.AemContext in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContentFragmentUtilsTest method getComponentExport.
@Test
public void getComponentExport() {
// GIVEN
AemContext slingContext = CoreComponentTestContext.newAemContext();
slingContext.load().json(this.getClass().getResourceAsStream("foo.json"), "/foo");
MockSlingHttpServletRequest slingHttpServletRequest = new MockSlingHttpServletRequest(slingContext.bundleContext());
ComponentExporter componentExporter = new TestComponentExporter();
ModelFactory modelFactory = Mockito.mock(ModelFactory.class);
Mockito.when(modelFactory.getModelFromWrappedRequest(Mockito.any(), Mockito.any(), Mockito.eq(ComponentExporter.class))).thenReturn(componentExporter);
// WHEN
Map<String, ComponentExporter> exporterMap = ContentFragmentUtils.getComponentExporters(slingContext.resourceResolver().getResource("/foo").listChildren(), modelFactory, slingHttpServletRequest, null);
// THEN
Assertions.assertEquals(componentExporter, exporterMap.get("bar"));
Assertions.assertEquals(componentExporter, exporterMap.get("qux"));
}
Aggregations