@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());
  }
  @Test
  public void testContentRequest_root_with_content_key() {
    SitePath sitePath = new SitePath(siteKey, "/contentName--123");
    final ContentKey contentKey = new ContentKey(123);
    ContentPath contentPath = new ContentPath(contentKey, "contentName", new Path("/"));
    sitePath.setContentPath(contentPath);

    SectionContentEntity sectionContent = createSectionContent(contentKey, "contentName");
    MenuItemEntity menuItem = new MenuItemEntity();
    addSectionContentToMenuItem(menuItem, sectionContent);

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

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

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNotNull(resolvedContentPath);
    assertEquals("123", resolvedContentPath.getContentKey().toString());
    assertNotNull(resolvedContext.getRequestedMenuItem());
    assertTrue(resolvedContext.getPageRequestType().equals(PageRequestType.CONTENT));
  }
  @Test
  public void testContentRequest_several_content_in_section() {
    SitePath sitePath = new SitePath(siteKey, "/test/path/contentName3");

    SectionContentEntity sectionContent = createSectionContent(new ContentKey(123), "contentName1");
    SectionContentEntity sectionContent2 =
        createSectionContent(new ContentKey(234), "contentName2");
    SectionContentEntity sectionContent3 =
        createSectionContent(new ContentKey(345), "contentName3");
    SectionContentEntity sectionContent4 =
        createSectionContent(new ContentKey(456), "contentName4");

    MenuItemEntity menuItem = new MenuItemEntity();
    addSectionContentToMenuItem(menuItem, sectionContent);
    addSectionContentToMenuItem(menuItem, sectionContent2);
    addSectionContentToMenuItem(menuItem, sectionContent3);
    addSectionContentToMenuItem(menuItem, sectionContent4);

    injectMenuItemToSiteEntityResolver("/test/path", menuItem);

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

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNotNull(resolvedContentPath);
    assertEquals("345", resolvedContentPath.getContentKey().toString());
    assertNotNull(resolvedContext.getRequestedMenuItem());
    assertTrue(resolvedContext.getPageRequestType().equals(PageRequestType.CONTENT));
  }
  @Test
  public void testContentRequest_with_content_key() {
    SitePath sitePath = new SitePath(siteKey, "/test/path/contentName--123");

    injectMenuItemToSiteEntityResolver("/test/path", new MenuItemEntity());
    injectContentIntoContentDao(new ContentKey(123), "contentName");

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

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNotNull(resolvedContentPath);
    assertEquals("123", resolvedContentPath.getContentKey().toString());
    assertNotNull(resolvedContext.getRequestedMenuItem());
    assertTrue(resolvedContext.getPageRequestType().equals(PageRequestType.CONTENT));
  }
  @Test
  public void testContentRequest_root_without_content_key() {
    SitePath sitePath = new SitePath(siteKey, "/contentName");

    SectionContentEntity sectionContent = createSectionContent(new ContentKey(123), "contentName");
    MenuItemEntity menuItem = new MenuItemEntity();
    addSectionContentToMenuItem(menuItem, sectionContent);

    injectMenuItemToSiteEntityResolver("/", menuItem);

    PageRequestContextResolver pageRequestContextResolver =
        new PageRequestContextResolver(contentDao);

    PageRequestContext resolvedContext =
        pageRequestContextResolver.resolvePageRequestContext(site, sitePath);
    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNull(resolvedContentPath);
    assertNull(resolvedContext.getRequestedMenuItem());
  }
  @Test
  public void testMenuItemRequest() {
    SitePath sitePath = new SitePath(siteKey, "/test/menuItem");

    SectionContentEntity sectionContent = createSectionContent(new ContentKey(123), "contentName");
    MenuItemEntity menuItem = new MenuItemEntity();
    addSectionContentToMenuItem(menuItem, sectionContent);

    injectMenuItemToSiteEntityResolver("/test/menuItem", menuItem);

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

    ContentPath resolvedContentPath = resolvedContext.getContentPath();
    assertNull(resolvedContentPath);
    assertNotNull(resolvedContext.getRequestedMenuItem());
    assertTrue(resolvedContext.getPageRequestType().equals(PageRequestType.MENUITEM));
  }
  @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);
  }