ComponentDataImpl implements ComponentData { @Override public String getJson() { try { return String.format("{\"%s\":%s}", getId(), new ObjectMapper().writeValueAsString(this)); } catch (JsonProcessingException e) { LOGGER.error("Unable to generate dataLayer JSON string", e); } return null; } ComponentDataImpl(@NotNull AbstractComponentImpl component, @NotNull Resource resource); @Override String getId(); @Override String getParentId(); @Override String getType(); @Override String getTitle(); @Override String getDescription(); @Override Date getLastModifiedDate(); @Override String getText(); @Override String getLinkUrl(); @Override String getJson();  }
@Test void getDataLayerJsonWhenDataLayerEnabled() { Title title = getTitleUnderTest(TITLE_RESOURCE_JCR_TITLE, true); assertNotNull(title.getData()); String expected = "{\"title-7968bee19c\":{\"@type\":\"core/wcm/components/title/v1/title\",\"dc:title\":\"Hello World\",\"repo:modifyDate\":\"2016-01-13T15:14:51Z\"}}"; assertEquals(Json.createReader(new StringReader(expected)).read(), Json.createReader(new StringReader(title.getData().getJson())).read()); Utils.testJSONExport(title, Utils.getTestExporterJSONPath(TEST_BASE, TITLE_RESOURCE_JCR_TITLE)); }