Examples of WidgetComment


Examples of org.apache.rave.portal.model.WidgetComment

    @Autowired
    private JpaWidgetCommentConverter widgetCommentConverter;

    @Test
    public void noConversion() {
        WidgetComment comment = new JpaWidgetComment();
        assertThat(widgetCommentConverter.convert(comment, null), is(sameInstance(comment)));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

        assertThat(widgetCommentConverter.convert(comment, null), is(sameInstance(comment)));
    }

    @Test
    public void nullConversion() {
        WidgetComment template = null;
        assertThat(widgetCommentConverter.convert(template, null), is(nullValue()));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

    }


    @Test
    public void newComment() {
        WidgetComment comment = new WidgetCommentImpl("9");
        comment.setCreatedDate(new Date());
        comment.setLastModifiedDate(new Date());
        comment.setText("hello");
        comment.setUserId("1");

        JpaWidgetComment converted = widgetCommentConverter.convert(comment, "9");
        assertThat(converted, is(not(sameInstance(comment))));
        assertThat(converted, is(instanceOf(JpaWidgetComment.class)));
        assertThat(converted.getCreatedDate(), is(equalTo(comment.getCreatedDate())));
        assertThat(converted.getEntityId().toString(), 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.getUserId(), is(equalTo(comment.getUserId())));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

    // checks to see if the Authentication object principal is the owner of the supplied widgetComment object
    // if trustedDomainObject is false, pull the entity from the database first to ensure
    // the model object is trusted and hasn't been modified
    private boolean isWidgetCommentOwner(Authentication authentication, WidgetComment widgetComment, List<WidgetComment> trustedPageContainer, boolean trustedDomainObject) {
        WidgetComment trustedWidgetComment = null;
        if (trustedDomainObject) {
            trustedWidgetComment = widgetComment;
        } else {
            trustedWidgetComment = getTrustedWidgetComment(widgetComment.getId(), trustedPageContainer);
        }

        return isWidgetCommentOwnerById(authentication, trustedWidgetComment.getUserId());
    }
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

    }

    // returns a trusted Page object, either from the PageRepository, or the
    // cached container list
    private WidgetComment getTrustedWidgetComment(String widgetCommentId, List<WidgetComment> trustedWidgetCommentContainer) {
        WidgetComment p = null;
        if (trustedWidgetCommentContainer.isEmpty()) {
            p = widgetRepository.getCommentById(null, widgetCommentId);
            trustedWidgetCommentContainer.add(p);
        } else {
            p = trustedWidgetCommentContainer.get(0);
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

        verify(httpServletResponse);
    }

    @Test
    public void getWidgetComment() {
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setEntityId(2L);
        expect(widgetCommentService.getWidgetComment(2L)).andReturn(widgetComment);
        replay(widgetCommentService);

        WidgetComment foundComment = widgetApi.getWidgetComment(1L, 2L);
        assertEquals(widgetComment.getEntityId(), foundComment.getEntityId());

        verify(widgetCommentService);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

    }

    @Test
    public void updateNonExistentWidgetComment() {
        String message = "message";
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setWidgetId(2L);
        widgetComment.setText(message);
        widgetComment.setUser(new User(VALID_USER_ID, "John.Doe"));

        expect(widgetCommentService.getWidgetComment(3L)).andReturn(null);
        widgetCommentService.saveWidgetComment(widgetComment);
        replay(widgetCommentService);
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

    }

    @Test
    public void updateWidgetComment() {
        String message = "updated comment";
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setEntityId(2L);

        expect(widgetCommentService.getWidgetComment(2L)).andReturn(widgetComment);
        widgetCommentService.saveWidgetComment(widgetComment);
        replay(widgetCommentService);

        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
        httpServletResponse.setStatus(HttpStatus.NO_CONTENT.value());
        replay(httpServletResponse);

        widgetApi.updateWidgetComment(1L, 2L, message, httpServletResponse);

        assertEquals(message, widgetComment.getText());

        verify(widgetCommentService);
        verify(httpServletResponse);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.WidgetComment

   
    @RequestMapping(method = RequestMethod.POST, value = "/{widgetId}/comments")
    public void createWidgetComment(@PathVariable long widgetId,
                                 @RequestParam String text,
                                 HttpServletResponse response) {
        WidgetComment widgetComment = new WidgetComment();
        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

Examples of org.apache.rave.portal.model.WidgetComment

    public void updateWidgetComment(@PathVariable long widgetId,
                                    @PathVariable long widgetCommentId,
                                    @RequestParam String text,
                                    HttpServletResponse response) {
       
        WidgetComment widgetComment = widgetCommentService.getWidgetComment(widgetCommentId);
        if (widgetComment == null) {
            widgetComment = new WidgetComment();
            widgetComment.setWidgetId(widgetId);
            widgetComment.setUser(userService.getAuthenticatedUser());
            widgetComment.setCreatedDate(new Date());
            widgetComment.setLastModifiedDate(new Date());
        }
        widgetComment.setText(text);
       
        widgetCommentService.saveWidgetComment(widgetComment);
       
        response.setStatus(HttpStatus.NO_CONTENT.value());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.