@Test
  public void testContentRequest_contentOnRoot() {

    SitePath sitePath = new SitePath(siteKey, "/123/contentName");

    final ContentKey contentKey = new ContentKey(123);

    final MenuItemEntity rootMenuItem = new MenuItemEntity();
    rootMenuItem.setName("");
    rootMenuItem.setKey(1);

    injectMenuItemToSiteEntityResolver("/", rootMenuItem);
    injectContentIntoContentDao(contentKey, "contentName");

    PageRequestContextResolver pageRequestContextResolver =
        new PageRequestContextResolver(contentDao);
    PageRequestContext resolvedContext =
        pageRequestContextResolver.resolvePageRequestContext(site, sitePath);

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNotNull(resolvedContentPath);
    assertNotNull(resolvedContext.getRequestedMenuItem());

    assertEquals(new ContentKey("123"), resolvedContentPath.getContentKey());
    assertEquals("/", resolvedContentPath.getPathToMenuItem().getPathAsString());
  }
Пример #2
0
 private MenuItemEntity createMenuItem(String key, String name, MenuItemEntity parent) {
   MenuItemEntity mi = new MenuItemEntity();
   mi.setKey(Integer.parseInt(key));
   mi.setName(name);
   if (parent != null) {
     mi.setParent(parent);
     parent.addChild(mi);
   }
   return mi;
 }
  @Test
  public void testContentRequest_contentOnRoot_extraElementInPath() {
    SitePath sitePath = new SitePath(siteKey, "/123/test/contentName");

    final ContentKey contentKey = new ContentKey(123);

    final MenuItemEntity rootMenuItem = new MenuItemEntity();
    rootMenuItem.setName("");
    rootMenuItem.setKey(1);

    injectRootPageOnSite(rootMenuItem);
    injectContentIntoContentDao(contentKey, "contentName");

    PageRequestContextResolver pageRequestContextResolver =
        new PageRequestContextResolver(contentDao);
    PageRequestContext resolvedContext =
        pageRequestContextResolver.resolvePageRequestContext(site, sitePath);

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNull(resolvedContentPath);
  }