コード例 #1
0
  @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);
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
ファイル: RenderBaseHandlerTest.java プロジェクト: enonic/xp
  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);
  }
コード例 #4
0
ファイル: RenderBaseHandlerTest.java プロジェクト: enonic/xp
  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);
  }