コード例 #1
0
  @Test
  public void moveTopicsDoesNotHaveRoleShouldIgnore() {
    when(roleManager.getCanMoveTopics()).thenReturn(false);

    controller.moveTopics(1, "return path", moderationLog, 1, 2);

    verify(mockResult).redirectTo("return path");
  }
コード例 #2
0
  @Test
  public void askMoveDestinationDoesNotHaveRoleShouldIgnore() {
    when(roleManager.getCanMoveTopics()).thenReturn(false);

    controller.askMoveDestination("return path", 1, 2, 3);

    verify(mockResult).redirectTo("return path");
  }
コード例 #3
0
  @Test
  public void approveDoesNotHaveRequiredRoleShouldIgnore() {
    when(roleManager.getCanApproveMessages()).thenReturn(false);
    when(mockResult.redirectTo(ForumController.class)).thenReturn(mockForumController);

    controller.approve(1, Arrays.asList(new ApproveInfo[0]));

    verify(mockForumController).show(1, 0);
  }
コード例 #4
0
  @Test
  public void lockUnlockDoesNotHaveRoleShouldIgnore() {
    when(roleManager.getCanLockUnlockTopics()).thenReturn(false);
    when(mockResult.redirectTo(ForumController.class)).thenReturn(mockForumController);

    controller.lockUnlock(1, null, moderationLog, new int[] {1});

    verify(mockForumController).show(1, 0);
  }
コード例 #5
0
  @Test
  public void moveTopics() {
    when(userSession.getUser()).thenReturn(user);
    when(roleManager.getCanMoveTopics()).thenReturn(true);

    controller.moveTopics(1, "return path", moderationLog, 2, 3, 4);

    verify(service).moveTopics(1, moderationLog, 2, 3, 4);
    verify(mockResult).redirectTo("return path");
  }
コード例 #6
0
  @Test
  public void deleteTopicsDoesNotHaveRoleShouldIgnore() {
    when(roleManager.getCanDeletePosts()).thenReturn(false);
    // TODO pass zero?
    when(mockResult.redirectTo(ForumController.class)).thenReturn(mockForumController);

    controller.deleteTopics(1, null, new int[] {4}, moderationLog);

    verify(mockForumController).show(1, 0);
  }
コード例 #7
0
  @Test
  public void lockUnlock() {
    when(userSession.getUser()).thenReturn(user);
    when(roleManager.getCanLockUnlockTopics()).thenReturn(true);
    when(mockResult.redirectTo(ForumController.class)).thenReturn(mockForumController);

    controller.lockUnlock(1, null, moderationLog, new int[] {1, 2, 3});

    verify(service).lockUnlock(new int[] {1, 2, 3}, moderationLog);
    verify(mockForumController).show(1, 0);
  }
コード例 #8
0
  @Test
  public void approveExpectSuccess() {
    when(roleManager.getCanApproveMessages()).thenReturn(true);
    when(mockResult.redirectTo(ForumController.class)).thenReturn(mockForumController);

    controller.approve(1, Arrays.asList(new ApproveInfo[0]));

    verify(service).doApproval(1, Arrays.asList(new ApproveInfo[0]));
    // TODO pass zero?
    verify(mockForumController).show(1, 0);
  }
コード例 #9
0
  @Test
  public void askMoveDestination() {
    when(roleManager.getCanMoveTopics()).thenReturn(true);
    when(categoryRepository.getAllCategories()).thenReturn(new ArrayList<Category>());

    controller.askMoveDestination("return path", 10, 1, 2, 3);

    assertArrayEquals(new int[] {1, 2, 3}, (int[]) mockResult.included("topicIds"));
    assertEquals(10, mockResult.included("fromForumId"));
    assertEquals("return path", mockResult.included("returnUrl"));
    assertEquals(new ArrayList<Category>(), mockResult.included("categories"));
  }
コード例 #10
0
  @Test
  public void deleteTopicsExpectSuccess() {
    when(userSession.getUser()).thenReturn(user);
    when(roleManager.getCanDeletePosts()).thenReturn(true);
    when(topicRepository.get(4)).thenReturn(new Topic());
    when(topicRepository.get(5)).thenReturn(new Topic());
    when(mockResult.redirectTo(ForumController.class)).thenReturn(mockForumController);

    controller.deleteTopics(1, null, new int[] {4, 5}, moderationLog);

    verify(service).deleteTopics(Arrays.asList(new Topic(), new Topic()), moderationLog);
    // TODO pass zero?
    verify(mockForumController).show(1, 0);
  }