Parsys implements ContainerExporter { @JsonIgnore public List<Item> getItems() { return items; }  @JsonIgnore List<Item> getItems(); @JsonIgnore String getWrapperElementName(); @JsonIgnore String getWrapperCss(); @JsonIgnore boolean isWrapperElement(); @Override @NotNull String getExportedType(); @Override @NotNull Map<String, ? extends ComponentExporter> getExportedItems(); @Override String @NotNull [] getExportedItemsOrder();  }
@Test void testWcmDisabledMode() { context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE); WCMMode.DISABLED.toRequest(context.request()); Parsys parsys = AdaptTo.notNull(context.request(), Parsys.class); List<Item> items = parsys.getItems(); assertEquals(2, items.size()); Item item1 = items.get(0); assertEquals(par1Resource.getPath(), item1.getResourcePath()); assertNull(item1.getResourceType()); assertEquals(SECTION_DEFAULT_CLASS_NAME, item1.getCssClassName()); assertFalse(item1.isNewArea()); Item item2 = items.get(1); assertEquals(par2Resource.getPath(), item2.getResourcePath()); assertNull(item2.getResourceType()); assertEquals(SECTION_DEFAULT_CLASS_NAME, item2.getCssClassName()); assertFalse(item2.isNewArea()); }
@Test void testNewAreaResourceTypeFromCurrentComponent() { context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE); context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE + "/" + NEWAREA_CHILD_NAME); WCMMode.EDIT.toRequest(context.request()); Parsys parsys = AdaptTo.notNull(context.request(), Parsys.class); List<Item> items = parsys.getItems(); Item item3 = items.get(2); assertEquals("/apps/" + RESOURCE_TYPE_SAMPLE + "/" + NEWAREA_CHILD_NAME, item3.getResourceType()); }
@Test void testNewAreaResourceTypeFromSuperComponent() { context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE, SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, SUPER_RESOURCE_TYPE_SAMPLE); context.create().resource("/apps/" + SUPER_RESOURCE_TYPE_SAMPLE); context.create().resource("/apps/" + SUPER_RESOURCE_TYPE_SAMPLE + "/" + NEWAREA_CHILD_NAME); WCMMode.EDIT.toRequest(context.request()); Parsys parsys = AdaptTo.notNull(context.request(), Parsys.class); List<Item> items = parsys.getItems(); Item item3 = items.get(2); assertEquals(SUPER_RESOURCE_TYPE_SAMPLE + "/" + NEWAREA_CHILD_NAME, item3.getResourceType()); }
@Test void testOtherParentParsysResource() { context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE); parsysResource = context.create().resource(page.getContentResource().getPath() + "/parsysOther"); par1Resource = context.create().resource(parsysResource.getPath() + "/par1"); context.request().setAttribute(RA_PARSYS_PARENT_RESOURCE, parsysResource); WCMMode.EDIT.toRequest(context.request()); Parsys parsys = AdaptTo.notNull(context.request(), Parsys.class); List<Item> items = parsys.getItems(); assertEquals(2, items.size()); Item item1 = items.get(0); assertEquals(par1Resource.getPath(), item1.getResourcePath()); assertNull(item1.getResourceType()); assertEquals(SECTION_DEFAULT_CLASS_NAME, item1.getCssClassName()); assertFalse(item1.isNewArea()); Item item2 = items.get(1); assertEquals(NEWAREA_RESOURCE_PATH, item2.getResourcePath()); assertEquals(FALLBACK_NEWAREA_RESOURCE_TYPE, item2.getResourceType()); assertEquals(NEWAREA_CSS_CLASS_NAME + " " + SECTION_DEFAULT_CLASS_NAME, item2.getCssClassName()); assertTrue(item2.isNewArea()); }
@Test void testComponentWithTagDecoration() { context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE); context.create().resource("/apps/sample/components/comp1/" + NameConstants.NN_HTML_TAG, NameConstants.PN_TAG_NAME, "article", "class", "css1"); WCMMode.EDIT.toRequest(context.request()); Parsys parsys = AdaptTo.notNull(context.request(), Parsys.class); List<Item> items = parsys.getItems(); assertEquals(3, items.size()); Item item1 = items.get(0); assertEquals(par1Resource.getPath(), item1.getResourcePath()); assertNull(item1.getResourceType()); assertEquals("css1 section", item1.getCssClassName()); assertEquals("article", item1.getElementName()); assertTrue(item1.isDecorate()); assertFalse(item1.isNewArea()); Item item2 = items.get(1); assertEquals(par2Resource.getPath(), item2.getResourcePath()); assertNull(item2.getResourceType()); assertEquals(SECTION_DEFAULT_CLASS_NAME, item2.getCssClassName()); assertEquals(DEFAULT_ELEMENT_NAME, item2.getElementName()); assertTrue(item2.isDecorate()); assertFalse(item2.isNewArea()); Item item3 = items.get(2); assertEquals(NEWAREA_RESOURCE_PATH, item3.getResourcePath()); assertEquals(FALLBACK_NEWAREA_RESOURCE_TYPE, item3.getResourceType()); assertEquals(NEWAREA_CSS_CLASS_NAME + " " + SECTION_DEFAULT_CLASS_NAME, item3.getCssClassName()); assertEquals(DEFAULT_ELEMENT_NAME, item3.getElementName()); assertTrue(item3.isDecorate()); assertTrue(item3.isNewArea()); }
@Test void testComponentWithNoTagDecoration() { context.create().resource("/apps/" + RESOURCE_TYPE_SAMPLE, PN_PARSYS_PARAGRAPH_NODECORATION_WCMMODE, new String[] { "edit" }); context.create().resource("/apps/sample/components/comp1/" + NameConstants.NN_HTML_TAG, NameConstants.PN_TAG_NAME, "article", "class", "css1"); WCMMode.EDIT.toRequest(context.request()); Parsys parsys = AdaptTo.notNull(context.request(), Parsys.class); List<Item> items = parsys.getItems(); assertEquals(3, items.size()); Item item1 = items.get(0); assertEquals(par1Resource.getPath(), item1.getResourcePath()); assertNull(item1.getResourceType()); assertEquals("css1 section", item1.getCssClassName()); assertEquals("article", item1.getElementName()); assertFalse(item1.isDecorate()); assertFalse(item1.isNewArea()); Item item2 = items.get(1); assertEquals(par2Resource.getPath(), item2.getResourcePath()); assertNull(item2.getResourceType()); assertEquals(SECTION_DEFAULT_CLASS_NAME, item2.getCssClassName()); assertEquals(DEFAULT_ELEMENT_NAME, item2.getElementName()); assertFalse(item2.isDecorate()); assertFalse(item2.isNewArea()); Item item3 = items.get(2); assertEquals(NEWAREA_RESOURCE_PATH, item3.getResourcePath()); assertEquals(FALLBACK_NEWAREA_RESOURCE_TYPE, item3.getResourceType()); assertEquals(NEWAREA_CSS_CLASS_NAME + " " + SECTION_DEFAULT_CLASS_NAME, item3.getCssClassName()); assertEquals(DEFAULT_ELEMENT_NAME, item3.getElementName()); assertTrue(item3.isDecorate()); assertTrue(item3.isNewArea()); }