@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")); }
@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); }
@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); }
@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); }
@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); }
@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); }
@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); }
@Test public void testeLista() { questoesController.lista(); List<Questao> questoes = result.included("lista"); assertNotNull(questoes); }