Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.PrivateMessage


        verify(mailService, times(0)).sendReceivedPrivateMessageNotification(JC_USER, pm);
    }

    @Test
    public void testGetMessageToMe() throws NotFoundException {
        PrivateMessage expected = new PrivateMessage(user, user, "title", "body");
        when(pmDao.get(PM_ID)).thenReturn(expected);
        when(pmDao.isExist(PM_ID)).thenReturn(true);

        PrivateMessage pm = pmService.get(PM_ID);

        assertEquals(pm, expected);
        assertTrue(pm.isRead());
        verify(pmDao).saveOrUpdate(pm);
        verify(userDataCache).decrementNewMessageCountFor(USERNAME);
    }
View Full Code Here


    @Test(expectedExceptions = NotFoundException.class)
    public void testGetNotFound() throws NotFoundException {
        when(pmDao.isExist(PM_ID)).thenReturn(false);

        PrivateMessage pm = pmService.get(PM_ID);
    }
View Full Code Here

        PrivateMessage pm = pmService.get(PM_ID);
    }

    @Test(expectedExceptions = NotFoundException.class)
    public void testGetNotFoundIfUserHasNoAccessToDeletedPmFromOutBox() throws NotFoundException {
        PrivateMessage message = new PrivateMessage(user, user, null, null);
        message.setStatus(PrivateMessageStatus.DELETED_FROM_OUTBOX);

        when(pmDao.get(PM_ID)).thenReturn(message);
        when(pmDao.isExist(PM_ID)).thenReturn(true);

        pmService.get(PM_ID);
View Full Code Here

        verify(pmDao).get(PM_ID);
    }

    @Test(expectedExceptions = NotFoundException.class)
    public void testGetNotFoundIfUserHasNoAccessToDeletePmFromInbox() throws NotFoundException {
        PrivateMessage message = new PrivateMessage(user, user, null, null);
        message.setStatus(PrivateMessageStatus.DELETED_FROM_INBOX);

        when(pmDao.get(PM_ID)).thenReturn(message);
        when(pmDao.isExist(PM_ID)).thenReturn(true);

        pmService.get(PM_ID);
View Full Code Here

    }


    @Test
    public void testGetReadAlreadyRead() throws NotFoundException {
        PrivateMessage expected = new PrivateMessage(user, user, "title", "body");
        expected.setRead(true);
        when(pmDao.get(PM_ID)).thenReturn(expected);
        when(pmDao.isExist(PM_ID)).thenReturn(true);

        PrivateMessage pm = pmService.get(PM_ID);

        verify(pmDao, never()).saveOrUpdate(pm);
        verify(userDataCache, never()).decrementNewMessageCountFor(USERNAME);
    }
View Full Code Here

        verify(userDataCache, never()).decrementNewMessageCountFor(USERNAME);
    }

    @Test
    public void testGetPrivateMessageInDraftStatus() throws NotFoundException {
        PrivateMessage message = new PrivateMessage(user, user, "title", "body");
        message.setStatus(PrivateMessageStatus.DRAFT);

        when(pmDao.get(PM_ID)).thenReturn(message);
        when(pmDao.isExist(PM_ID)).thenReturn(true);

        PrivateMessage resultMessage = pmService.get(PM_ID);

        assertEquals(resultMessage.isRead(), false,
                "Message status is draft, so message shouldn't be marked as read");
        verify(pmDao, never()).saveOrUpdate(resultMessage);
        verify(userDataCache, never()).decrementNewMessageCountFor(USERNAME);
    }
View Full Code Here

        verify(userDataCache, never()).decrementNewMessageCountFor(USERNAME);
    }

    @Test
    public void testGetPrivateMessageUserToNotCurrentUser() throws NotFoundException {
        PrivateMessage message = new PrivateMessage(user, user, "title", "body");
        JCUser currentUser = new JCUser(USERNAME, "email", "password");

        when(pmDao.get(PM_ID)).thenReturn(message);
        when(pmDao.isExist(PM_ID)).thenReturn(true);
        when(userService.getCurrentUser()).thenReturn(currentUser);

        PrivateMessage resultMessage = pmService.get(PM_ID);

        assertEquals(resultMessage.isRead(), false,
                "The message isn't addressed to the current user, so message shouldn't be marked as read.");
        verify(pmDao, never()).saveOrUpdate(resultMessage);
        verify(userDataCache, never()).decrementNewMessageCountFor(USERNAME);
    }
View Full Code Here

        verify(userDataCache, never()).decrementNewMessageCountFor(USERNAME);
    }

    @Test
    public void testDeleteDrafts() throws NotFoundException {
        PrivateMessage message = new PrivateMessage(null, null, null, null);
        message.setStatus(PrivateMessageStatus.DRAFT);

        when(pmDao.get(1L)).thenReturn(message);
        when(pmDao.get(2L)).thenReturn(message);
        when(pmDao.isExist(1L)).thenReturn(true);
        when(pmDao.isExist(2L)).thenReturn(true);
View Full Code Here

    @Test
    public void testDeleteFromInbox() throws NotFoundException {
        JCUser otherUser = new JCUser(USERNAME, null, null);

        PrivateMessage message1 = new PrivateMessage(user, otherUser, null, null);
        message1.setStatus(PrivateMessageStatus.SENT);

        PrivateMessage message2 = new PrivateMessage(user, otherUser, null, null);
        message2.setStatus(PrivateMessageStatus.SENT);

        PrivateMessage message3 = new PrivateMessage(user, otherUser, null, null);
        message3.setStatus(PrivateMessageStatus.DELETED_FROM_OUTBOX);


        when(pmDao.get(1L)).thenReturn(message1);
        when(pmDao.get(2L)).thenReturn(message2);
        when(pmDao.get(3L)).thenReturn(message3);
View Full Code Here

    @Test
    public void testDeleteFromOutbox() throws NotFoundException {
        JCUser otherUser = new JCUser(USERNAME, null, null);

        PrivateMessage message1 = new PrivateMessage(otherUser, user, null, null);
        message1.setStatus(PrivateMessageStatus.SENT);

        PrivateMessage message2 = new PrivateMessage(otherUser, user, null, null);
        message2.setStatus(PrivateMessageStatus.SENT);

        PrivateMessage message3 = new PrivateMessage(otherUser, user, null, null);
        message3.setStatus(PrivateMessageStatus.DELETED_FROM_INBOX);

        when(pmDao.get(1L)).thenReturn(message1);
        when(pmDao.get(2L)).thenReturn(message2);
        when(pmDao.get(3L)).thenReturn(message3);
        when(pmDao.isExist(1L)).thenReturn(true);
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.PrivateMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.