@Test
  public void createUrl_withId_notFound() {
    final Content content = ContentFixtures.newContent();
    Mockito.when(this.contentService.getById(content.getId()))
        .thenThrow(new ContentNotFoundException(content.getId(), Branch.from("draft")));

    final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456");

    final String url = this.service.pageUrl(params);
    assertEquals(
        "/portal/draft/context/path/_/error/404?message=Content+with+id+%5B123456%5D+was+not+found+in+branch+%5Bdraft%5D",
        url);
  }
  @Test
  public void createUrl_withId() {
    final Content content = ContentFixtures.newContent();
    Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);

    final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456");

    final String url = this.service.pageUrl(params);
    assertEquals("/portal/draft/a/b/mycontent", url);
  }
Exemplo n.º 3
0
  protected final void setupContentAndSite() throws Exception {
    final Content content = createPage("id", "site/somepath/content", "myapplication:ctype", true);

    Mockito.when(
            this.contentService.getByPath(ContentPath.from("site/somepath/content").asAbsolute()))
        .thenReturn(content);

    Mockito.when(this.contentService.getNearestSite(Mockito.isA(ContentId.class)))
        .thenReturn(createSite("id", "site", "myapplication:contenttypename"));

    Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
  }
Exemplo n.º 4
0
  protected final void setupCustomizedTemplateContentAndSite() throws Exception {
    Content content = createPage("id", "site/somepath/content", "myapplication:ctype", true);
    final PageDescriptor controllerDescriptor = createDescriptor();
    Page page =
        Page.create(content.getPage())
            .template(null)
            .controller(controllerDescriptor.getKey())
            .build();
    content = Content.create(content).page(page).build();

    Mockito.when(
            this.contentService.getByPath(ContentPath.from("site/somepath/content").asAbsolute()))
        .thenReturn(content);

    Mockito.when(this.contentService.getNearestSite(Mockito.isA(ContentId.class)))
        .thenReturn(createSite("id", "site", "myapplication:contenttypename"));

    Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
  }