Package org.jtalks.jcommune.model.entity

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


     * @return {@code ModelAndView} with the message having filled recipient, title, message fields
     * @throws NotFoundException when message not found
     */
    @RequestMapping(value = "/quote/{pmId}", method = RequestMethod.GET)
    public ModelAndView quotePage(@PathVariable(PM_ID) Long id) throws NotFoundException {
        PrivateMessage pm = pmService.get(id);
        PrivateMessageDto dto = PrivateMessageDto.getReplyDtoFor(pm);
        dto.setBody(bbCodeService.quote(pm.getBody(), pm.getUserFrom()));
        return new ModelAndView(PM_FORM).addObject(DTO, dto);
    }
View Full Code Here


     * @return {@code ModelAndView} with a message
     * @throws NotFoundException when message not found
     */
    @RequestMapping(value = {"/pm/inbox/{pmId}", "/pm/outbox/{pmId}"}, method = RequestMethod.GET)
    public ModelAndView showPmPage(@PathVariable(PM_ID) Long id) throws NotFoundException {
        PrivateMessage pm = pmService.get(id);
        return new ModelAndView("pm/showPm")
                .addObject("pm", pm)
                .addObject("user", userService.getCurrentUser());
    }
View Full Code Here

     * @return private message form view and populated form dto
     * @throws NotFoundException when message not found
     */
    @RequestMapping(value = "/pm/drafts/{pmId}/edit", method = RequestMethod.GET)
    public ModelAndView editDraftPage(@PathVariable(PM_ID) Long id) throws NotFoundException {
        PrivateMessage pm = pmService.get(id);
        if (!pm.getStatus().equals(PrivateMessageStatus.DRAFT)) {
            // todo: 404? we need something more meaninful here
            throw new NotFoundException("Edit allowed only for draft messages.");
        }
        return new ModelAndView(PM_FORM).addObject(DTO, PrivateMessageDto.getFullPmDtoFor(pm));
    }
View Full Code Here

    }

    @Test
    public void testGetInboxForCurrentUser() {
        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.getAllForUser(eq(user), Matchers.<PageRequest>any())).thenReturn(expectedPage);

        Page<PrivateMessage> actual = pmService.getInboxForCurrentUser(pageNumber);
View Full Code Here

    }

    @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);
View Full Code Here

        when(securityService.<User>createAclBuilder()).thenReturn(aclBuilder);
        when(propertyDao.getByName(PROPERTY_NAME)).
                thenReturn(new Property(PROPERTY_NAME, String.valueOf(SENDING_NOTIFICATIONS_ENABLED)));

        JC_USER.setSendPmNotification(SENDING_NOTIFICATIONS_ENABLED);
        PrivateMessage pm = pmService.sendMessage("body", "title", JC_USER, user);

        assertFalse(pm.isRead());
        assertEquals(pm.getStatus(), PrivateMessageStatus.SENT);
        verify(userDataCache).incrementNewMessageCountFor(USERNAME);
        verify(pmDao).saveOrUpdate(pm);
        verify(aclBuilder, times(2)).grant(GeneralPermission.READ);
        verify(propertyDao).getByName(PROPERTY_NAME);
        verify(mailService, times(1)).sendReceivedPrivateMessageNotification(JC_USER, pm);
View Full Code Here

        when(propertyDao.getByName(PROPERTY_NAME)).
                thenReturn(new Property(PROPERTY_NAME, String.valueOf(SENDING_NOTIFICATIONS_DISABLED)));

        JC_USER.setSendPmNotification(SENDING_NOTIFICATIONS_DISABLED);
        PrivateMessage pm = pmService.sendMessage("body", "title", JC_USER, user);

        assertFalse(pm.isRead());
        assertEquals(pm.getStatus(), PrivateMessageStatus.SENT);
        verify(userDataCache).incrementNewMessageCountFor(USERNAME);
        verify(pmDao).saveOrUpdate(pm);
        verify(aclBuilder, times(2)).grant(GeneralPermission.READ);
        verify(propertyDao).getByName(PROPERTY_NAME);
        verify(mailService, times(0)).sendReceivedPrivateMessageNotification(JC_USER,pm);
View Full Code Here

    }

    @Test
    public void testGetDraftsForCurrentUser() {
        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.getDraftsForUser(eq(user), Matchers.<PageRequest>any())).thenReturn(expectedPage);

        Page<PrivateMessage> actual = pmService.getDraftsForCurrentUser(pageNumber);
View Full Code Here

        when(securityService.<User>createAclBuilder()).thenReturn(aclBuilder);
        when(propertyDao.getByName(PROPERTY_NAME)).
                thenReturn(new Property(PROPERTY_NAME, String.valueOf(SENDING_NOTIFICATIONS_ENABLED)));

        JC_USER.setSendPmNotification(SENDING_NOTIFICATIONS_ENABLED);
        PrivateMessage pm = pmService.sendDraft(1L, "body", "title", JC_USER, user);

        assertFalse(pm.isRead());
        assertEquals(pm.getStatus(), PrivateMessageStatus.SENT);
        verify(userDataCache).incrementNewMessageCountFor(USERNAME);
        verify(pmDao).saveOrUpdate(pm);
        verify(securityService).deleteFromAcl(pm);
        verify(aclBuilder, times(2)).grant(GeneralPermission.READ);
        verify(propertyDao).getByName(PROPERTY_NAME);
View Full Code Here

        when(securityService.<User>createAclBuilder()).thenReturn(aclBuilder);
        when(propertyDao.getByName(PROPERTY_NAME)).
                thenReturn(new Property(PROPERTY_NAME, String.valueOf(SENDING_NOTIFICATIONS_DISABLED)));

        JC_USER.setSendPmNotification(SENDING_NOTIFICATIONS_DISABLED);
        PrivateMessage pm = pmService.sendDraft(1L, "body", "title", JC_USER, user);

        assertFalse(pm.isRead());
        assertEquals(pm.getStatus(), PrivateMessageStatus.SENT);
        verify(userDataCache).incrementNewMessageCountFor(USERNAME);
        verify(pmDao).saveOrUpdate(pm);
        verify(securityService).deleteFromAcl(pm);
        verify(aclBuilder, times(2)).grant(GeneralPermission.READ);
        verify(propertyDao).getByName(PROPERTY_NAME);
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.