Package org.apache.rave.portal.model.impl

Examples of org.apache.rave.portal.model.impl.WidgetCommentImpl


        widget.setComments(convertedComments);
    }


    private WidgetCommentImpl convert(WidgetComment comment, Widget widget) {
        WidgetCommentImpl converted = comment instanceof WidgetCommentImpl ? ((WidgetCommentImpl) comment) : new WidgetCommentImpl();
        converted.setUserId(comment.getUserId());
        converted.setId(comment.getId() == null ? generateId() : comment.getId());

        converted.setCreatedDate(comment.getCreatedDate());
        converted.setLastModifiedDate(comment.getLastModifiedDate());
        converted.setText(comment.getText());
        return converted;
    }
View Full Code Here


    @RequestMapping(method = RequestMethod.POST, value = "/{widgetId}/comments")
    public void createWidgetComment(@PathVariable long widgetId,
                                    @RequestParam String text,
                                    HttpServletResponse response) {
        WidgetComment widgetComment = new WidgetCommentImpl();
        widgetComment.setWidgetId(widgetId);
        widgetComment.setUser(userService.getAuthenticatedUser());
        widgetComment.setText(text);
        widgetComment.setCreatedDate(new Date());
        widgetComment.setLastModifiedDate(new Date());

        widgetCommentService.saveWidgetComment(widgetComment);

        response.setStatus(HttpStatus.NO_CONTENT.value());
    }
View Full Code Here

                                    @RequestParam String text,
                                    HttpServletResponse response) {

        WidgetComment widgetComment = widgetCommentService.getWidgetComment(widgetCommentId);
        if (widgetComment == null) {
            widgetComment = new WidgetCommentImpl();
            widgetComment.setWidgetId(widgetId);
            widgetComment.setUser(userService.getAuthenticatedUser());
            widgetComment.setCreatedDate(new Date());
            widgetComment.setLastModifiedDate(new Date());
        }
View Full Code Here

    @Transactional(readOnly=false)
    @Rollback(true)
    public void delete_implObject() {
        WidgetComment wc = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(wc, is(notNullValue()));
        WidgetComment impl = new WidgetCommentImpl(wc.getId());
        repository.delete(impl);
        wc = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(wc, is(nullValue()));
    }
View Full Code Here

    }


    @Test
    public void newComment() {
        WidgetComment comment = new WidgetCommentImpl();
        comment.setCreatedDate(new Date());
        comment.setId(9L);
        comment.setLastModifiedDate(new Date());
        comment.setText("hello");
        comment.setUser(new JpaUser(1L));
        comment.setWidgetId(9L);

        JpaWidgetComment converted = widgetCommentConverter.convert(comment);
        assertThat(converted, is(not(sameInstance(comment))));
        assertThat(converted, is(instanceOf(JpaWidgetComment.class)));
        assertThat(converted.getCreatedDate(), is(equalTo(comment.getCreatedDate())));
        assertThat(converted.getEntityId(), is(equalTo(comment.getId())));
        assertThat(converted.getId(), is(equalTo(comment.getId())));
        assertThat(converted.getLastModifiedDate(), is(equalTo(comment.getLastModifiedDate())));
        assertThat(converted.getText(), is(equalTo(comment.getText())));
        assertThat(converted.getUser(), is(equalTo(comment.getUser())));
        assertThat(converted.getWidgetId(), is(equalTo(comment.getWidgetId())));
    }
View Full Code Here

        widgetCommentService = new DefaultWidgetCommentService(widgetCommentRepository);
    }

    @Test
    public void getWidgetComment() {
        WidgetComment comment = new WidgetCommentImpl();
        comment.setId(1L);
        expect(widgetCommentRepository.get(1L)).andReturn(comment);
        replay(widgetCommentRepository);

        assertEquals(comment, widgetCommentService.getWidgetComment(1L));
        verify(widgetCommentRepository);
View Full Code Here

        verify(widgetCommentRepository);
    }

    @Test
    public void saveWidgetComment() {
        WidgetComment comment = new WidgetCommentImpl();
        comment.setId(1L);
        expect(widgetCommentRepository.save(comment)).andReturn(comment);
        replay(widgetCommentRepository);

        widgetCommentService.saveWidgetComment(comment);
        verify(widgetCommentRepository);
View Full Code Here

        verify(widgetCommentRepository);
    }

    @Test
    public void deleteWidgetComment() {
        WidgetComment comment = new WidgetCommentImpl();
        comment.setId(1L);
        expect(widgetCommentRepository.get(1L)).andReturn(comment);
        widgetCommentRepository.delete(comment);
        replay(widgetCommentRepository);

        widgetCommentService.removeWidgetComment(1L);
View Full Code Here

        user.setUsername(VALID_USERNAME);
        user.setId(VALID_USER_ID);
        user2 = new UserImpl();
        user2.setUsername(VALID_USERNAME2);
        user2.setId(INVALID_USER_ID);
        widgetComment = new WidgetCommentImpl();
        widgetComment.setId(VALID_COMMENT_ID);
        widgetComment.setUser(user);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
View Full Code Here

        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthoritiesList).anyTimes();
        expect(mockAuthentication.getPrincipal()).andReturn(user).anyTimes();
        replay(mockAuthentication);

        WidgetComment localWidgetComment = new WidgetCommentImpl();
        UserImpl localUser = new UserImpl();
        localUser.setId(VALID_USER_ID);
        localWidgetComment.setUser(localUser);
        expect(mockWidgetCommentRepository.get(VALID_COMMENT_ID)).andReturn(localWidgetComment).anyTimes();
        replay(mockWidgetCommentRepository);

        assertThat(defaultWidgetCommentPermissionEvaluator.hasPermission(mockAuthentication, localWidgetComment, Permission.CREATE), is(true));
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.impl.WidgetCommentImpl

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.