Package org.jtalks.jcommune.model.entity

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


    }

    @Test
    public void inboxPage() {
        String page = "1";
        List<PrivateMessage> messages = Arrays.asList(new PrivateMessage(JC_USER, JC_USER,
                "Message title", "Private message body"));
        Page<PrivateMessage> expectedPage = new PageImpl<>(messages);

        when(pmService.getInboxForCurrentUser(page)).thenReturn(expectedPage);
        when(userService.getCurrentUser()).thenReturn(JC_USER);
View Full Code Here


    }

    @Test
    public void outboxPage() {
        String page = "1";
        List<PrivateMessage> messages = Arrays.asList(new PrivateMessage(JC_USER, JC_USER,
                "Message title", "Private message body"));
        Page<PrivateMessage> expectedPage = new PageImpl<>(messages);

        when(pmService.getOutboxForCurrentUser(page)).thenReturn(expectedPage);
        when(userService.getCurrentUser()).thenReturn(JC_USER);
View Full Code Here

    }

    @Test
    public void draftsPage() {
        String page = "1";
        List<PrivateMessage> messages = Arrays.asList(new PrivateMessage(JC_USER, JC_USER,
                "Message title", "Private message body"));
        Page<PrivateMessage> expectedPage = new PageImpl<>(messages);

        when(pmService.getDraftsForCurrentUser(page)).thenReturn(expectedPage);
View Full Code Here

        controller.sendMessage(dto, bindingResult);
    }

    @Test
    public void replyPage() throws NotFoundException {
        PrivateMessage pm = getPrivateMessage();
        //set expectations
        when(pmService.get(PM_ID)).thenReturn(pm);

        //invoke the object under test
        ModelAndView mav = controller.replyPage(PM_ID);
View Full Code Here

        assertAndReturnModelAttributeOfType(mav, "privateMessageDto", PrivateMessageDto.class);
    }

    @Test
    public void quotePage() throws NotFoundException {
        PrivateMessage pm = getPrivateMessage();
        //set expectations
        when(pmService.get(PM_ID)).thenReturn(pm);

        //invoke the object under test
        ModelAndView mav = controller.quotePage(PM_ID);
View Full Code Here

        assertAndReturnModelAttributeOfType(mav, "privateMessageDto", PrivateMessageDto.class);
    }

    @Test
    public void showPmPageInbox() throws NotFoundException {
        PrivateMessage pm = getPrivateMessage();

        //set expectations
        when(pmService.get(PM_ID)).thenReturn(pm);

        //invoke the object under test
        ModelAndView mav = controller.showPmPage(PM_ID);

        //check expectations
        verify(pmService).get(PM_ID);

        //check result
        assertViewName(mav, "pm/showPm");
        PrivateMessage actualPm = assertAndReturnModelAttributeOfType(mav, "pm", PrivateMessage.class);
        assertEquals(actualPm, pm);
    }
View Full Code Here

        verify(pmService).get(PM_ID);
    }

    @Test
    public void editDraftPage() throws NotFoundException {
        PrivateMessage pm = getPrivateMessage();
        pm.setId(PM_ID);
        pm.setStatus(PrivateMessageStatus.DRAFT);

        //set expectations
        when(pmService.get(PM_ID)).thenReturn(pm);

        //invoke the object under test
View Full Code Here

        assertEquals(dto.getId(), PM_ID);
    }

    @Test(expectedExceptions = NotFoundException.class)
    public void editDraftPageNotDraft() throws NotFoundException {
        PrivateMessage pm = getPrivateMessage();
        when(pmService.get(PM_ID)).thenReturn(pm);

        controller.editDraftPage(PM_ID);
    }
View Full Code Here

        dto.setRecipient(USERNAME);
        return dto;
    }

    private PrivateMessage getPrivateMessage() {
        return new PrivateMessage(new JCUser("username", "email", "password"),
                new JCUser("username2", "email2", "password2"), "title", "body");
    }
View Full Code Here

     * @return {@code ModelAndView} with the message having filled recipient, title fields
     * @throws NotFoundException when message not found
     */
    @RequestMapping(value = "/reply/{pmId}", method = RequestMethod.GET)
    public ModelAndView replyPage(@PathVariable(PM_ID) Long id) throws NotFoundException {
        PrivateMessage pm = pmService.get(id);
        PrivateMessageDto object = PrivateMessageDto.getReplyDtoFor(pm);
        return new ModelAndView(PM_FORM).addObject(DTO, object);
    }
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.