コード例 #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
ファイル: ContextBuilderTest.java プロジェクト: ponomandr/xp
  @Test
  public void copy_construct_with_overwrite() throws Exception {

    final Context old =
        ContextBuilder.create()
            .repositoryId("repository")
            .branch("branch")
            .attribute("key1", "value1")
            .build();

    final Branch newWS = Branch.from("new");
    final Context newContext = ContextBuilder.from(old).branch(newWS).build();

    assertEquals(newWS, newContext.getBranch());
    assertEquals("repository", newContext.getRepositoryId().toString());
  }
コード例 #3
0
  @Test
  public void testContentNotFoundById() throws Exception {
    Mockito.when(this.contentService.getByPath(Mockito.any()))
        .thenThrow(
            new ContentNotFoundException(
                ContentId.from("ee70f5d0-025c-4fbd-a835-5e50ff7b76ba"), Branch.from("draft")));

    SecurityService securityService = Mockito.mock(SecurityService.class);
    addService(SecurityService.class, securityService);

    final Optional<? extends Principal> value = Optional.of(User.ANONYMOUS);
    Mockito.<Optional<? extends Principal>>when(
            securityService.getPrincipal(Mockito.any(PrincipalKey.class)))
        .thenReturn(value);

    runFunction("/site/test/SetPermissionsHandlerTest.js", "setPermissionsNotFoundById");
  }