### Question:
TransactionalPrivateMessageService extends AbstractTransactionalEntityService<PrivateMessage, PrivateMessageDao> implements PrivateMessageService { @Override public Page<PrivateMessage> getOutboxForCurrentUser(String page) { JCUser currentUser = userService.getCurrentUser(); PageRequest pageRequest = new PageRequest(page, currentUser.getPageSize()); return this.getDao().getAllFromUser(currentUser, pageRequest); } TransactionalPrivateMessageService(PrivateMessageDao pmDao,
                                              SecurityService securityService,
                                              UserService userService,
                                              UserDataCacheService userDataCache,
                                              MailService mailService,
                                              JCommuneProperty sendingNotificationsEnabledProperty); @Override Page<PrivateMessage> getInboxForCurrentUser(String page); @Override Page<PrivateMessage> getOutboxForCurrentUser(String page); @Override @PreAuthorize("hasPermission(#userFrom.id, 'USER', 'ProfilePermission.SEND_PRIVATE_MESSAGES')") PrivateMessage sendMessage(String title, String body, JCUser recipient, JCUser userFrom); @Override Page<PrivateMessage> getDraftsForCurrentUser(String page); @Override @PreAuthorize("hasPermission(#userFrom.id, 'USER', 'ProfilePermission.SEND_PRIVATE_MESSAGES')") void saveDraft(long id, JCUser userTo, String title, String body, JCUser userFrom); @Override int currentUserNewPmCount(); @Override @PreAuthorize("hasPermission(#userFrom.id, 'USER', 'ProfilePermission.SEND_PRIVATE_MESSAGES')") PrivateMessage sendDraft(long id, String title, String body,
                                    JCUser recipient, JCUser userFrom); @Override @PreAuthorize("hasPermission(#id, 'PRIVATE_MESSAGE', 'GeneralPermission.READ')") PrivateMessage get(Long id); @Override String delete(List<Long> ids); @Override @PreAuthorize("hasPermission(#senderId, 'USER', 'ProfilePermission.SEND_PRIVATE_MESSAGES')") void checkPermissionsToSend(Long senderId); static final int DEFAULT_MESSAGE_COUNT; }### Answer:
@Test public void testGetOutboxForCurrentUser() { String pageNumber = "1"; List<PrivateMessage> messages = Arrays.asList(new PrivateMessage(user, user, "Message title", "Private message body")); Page<PrivateMessage> expectedPage = new PageImpl<>(messages); when(pmDao.getAllFromUser(eq(user), Matchers.<PageRequest>any())).thenReturn(expectedPage); Page<PrivateMessage> actual = pmService.getOutboxForCurrentUser(pageNumber); verify(pmDao).getAllFromUser(eq(user), Matchers.<PageRequest>any()); assertEquals(expectedPage, actual); }