Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ExtendWith({ AemContextExtension.class, MockitoExtension.class })
- class JSONExporterServiceImplTest {
- private JSONExporterServiceImpl jsonExporterServiceImpl;
- private final AemContext context = new AemContext(ResourceResolverType.RESOURCERESOLVER_MOCK);
- @Mock
- private ModelFactory modelFactory;
- String json;
- private GamesModel gamesModel;
- @BeforeEach
- void setUp() throws Exception {
- context.load().json("/com/warner/media/core/services/sample-content.json","/content");
- context.currentResource("/content");
- json= "{description=games, sling:resourceType=warner/components/games, jcr:primaryType=nt:unstructured, title=gamescomponent}";
- context.registerService(ModelFactory.class, modelFactory, org.osgi.framework.Constants.SERVICE_RANKING,
- Integer.MAX_VALUE);
- jsonExporterServiceImpl=context.registerInjectActivateService(new JSONExporterServiceImpl());
- }
- @Test
- void testGetContentPageJson() throws PostConstructException, MissingElementsException, InvalidAdaptableException, ModelClassException, ValidationException, InvalidModelException, ExportException, MissingExporterException {
- assertEquals("warner/components/container",context.currentResource().getChild("/content/root/container").getResourceType());
- lenient().when(modelFactory.exportModelForResource(context.currentResource().getChild("/content/root/container/cncontainer/games1"), "jackson", String.class, new HashMap<String,String>())).thenReturn(json);
- jsonExporterServiceImpl.getContentPageJson(context.request(), context.currentResource(), context.resourceResolver());
- }
Add Comment
Please, Sign In to add comment