Ejemplo n.º 1
0
  @Test
  public void testEditMode_Customized() {
    when(component.getProperties())
        .thenReturn(
            ImmutableValueMap.builder()
                .put(PN_PARSYS_GENERATE_DEAFULT_CSS, false)
                .put(PN_PARSYS_PARAGRAPH_CSS, "paracss")
                .put(PN_PARSYS_NEWAREA_CSS, "newareacss")
                .put(PN_PARSYS_PARAGRAPH_ELEMENT, "li")
                .put(PN_PARSYS_WRAPPER_ELEMENT, "ul")
                .put(PN_PARSYS_WRAPPER_CSS, "wrappercss")
                .build());

    WCMMode.EDIT.toRequest(context.request());
    Parsys parsys = context.request().adaptTo(Parsys.class);

    assertTrue(parsys.isWrapperElement());
    assertEquals("wrappercss", parsys.getWrapperCss());
    assertEquals("ul", parsys.getWrapperElementName());

    List<Item> items = parsys.getItems();
    assertEquals(3, items.size());

    Item item1 = items.get(0);
    assertEquals(par1Resource.getPath(), item1.getResourcePath());
    assertNull(item1.getResourceType());
    assertNull(item1.getStyle());
    assertEquals("paracss", item1.getCssClassName());
    assertEquals("li", item1.getElementName());
    assertFalse(item1.isNewArea());

    Item item2 = items.get(1);
    assertEquals(par2Resource.getPath(), item2.getResourcePath());
    assertNull(item2.getResourceType());
    assertNull(item2.getStyle());
    assertEquals("paracss", item2.getCssClassName());
    assertEquals("li", item2.getElementName());
    assertFalse(item2.isNewArea());

    Item item3 = items.get(2);
    assertEquals(NEWAREA_RESOURCE_PATH, item3.getResourcePath());
    assertEquals(FALLBACK_NEWAREA_RESOURCE_TYPE, item3.getResourceType());
    assertNull(item3.getStyle());
    assertEquals(NEWAREA_CSS_CLASS_NAME + " newareacss", item3.getCssClassName());
    assertEquals("li", item3.getElementName());
    assertTrue(item3.isNewArea());
  }
Ejemplo n.º 2
0
  @Test
  public void testEditMode() {
    WCMMode.EDIT.toRequest(context.request());
    Parsys parsys = context.request().adaptTo(Parsys.class);

    assertFalse(parsys.isWrapperElement());
    assertNull(parsys.getWrapperCss());
    assertEquals(DEFAULT_ELEMENT_NAME, parsys.getWrapperElementName());

    List<Item> items = parsys.getItems();
    assertEquals(3, items.size());

    Item item1 = items.get(0);
    assertEquals(par1Resource.getPath(), item1.getResourcePath());
    assertNull(item1.getResourceType());
    assertNull(item1.getStyle());
    assertEquals(SECTION_DEFAULT_CLASS_NAME, item1.getCssClassName());
    assertEquals(DEFAULT_ELEMENT_NAME, item1.getElementName());
    assertFalse(item1.isNewArea());

    Item item2 = items.get(1);
    assertEquals(par2Resource.getPath(), item2.getResourcePath());
    assertNull(item2.getResourceType());
    assertNull(item2.getStyle());
    assertEquals(SECTION_DEFAULT_CLASS_NAME, item2.getCssClassName());
    assertEquals(DEFAULT_ELEMENT_NAME, item2.getElementName());
    assertFalse(item2.isNewArea());

    Item item3 = items.get(2);
    assertEquals(NEWAREA_RESOURCE_PATH, item3.getResourcePath());
    assertEquals(FALLBACK_NEWAREA_RESOURCE_TYPE, item3.getResourceType());
    assertEquals(NEWAREA_STYLE, item3.getStyle());
    assertEquals(
        NEWAREA_CSS_CLASS_NAME + " " + SECTION_DEFAULT_CLASS_NAME, item3.getCssClassName());
    assertEquals(DEFAULT_ELEMENT_NAME, item3.getElementName());
    assertTrue(item3.isNewArea());
  }