Package org.apache.rave.model

Examples of org.apache.rave.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


    }

    // 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

    @Autowired
    private JpaWidgetCommentConverter widgetCommentConverter;

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

        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

    }


    @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

        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.setUserId(VALID_USER_ID);
        expect(widgetRepository.getCommentById(null, VALID_COMMENT_ID)).andReturn(localWidgetComment).anyTimes();
        replay(widgetRepository);

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

        wc.setUserId(VALID_USER_ID.toString());
        assertThat(wc.getId(), is(nullValue()));
        repository.createWidgetComment(VALID_WIDGET_ID.toString(), wc);
        String newId = wc.getId();
        assertThat(Long.parseLong(newId) > 0, is(true));
        WidgetComment newComment = repository.getCommentById(VALID_WIDGET_ID.toString(), newId);
        assertThat(newComment.getUserId(), is(VALID_USER_ID.toString()));
        assertThat(newComment.getText(), is(text));
        assertThat(newComment.getCreatedDate(), is(createdDate));
        assertThat(newComment.getLastModifiedDate(), is(lastModDate));
    }
View Full Code Here

    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_existing() {
        final String UPDATED_TEXT = "updated comment";
        WidgetComment widgetComment = repository.getCommentById(VALID_WIDGET_ID.toString(), VALID_WIDGET_COMMENT_ID.toString());
        assertThat(widgetComment.getText(), is(not(UPDATED_TEXT)));
        widgetComment.setText(UPDATED_TEXT);
        repository.createWidgetComment(VALID_WIDGET_ID.toString(), widgetComment);
        WidgetComment updatedComment = repository.getCommentById(VALID_WIDGET_ID.toString(), VALID_WIDGET_COMMENT_ID.toString());
        assertThat(updatedComment.getText(), is(UPDATED_TEXT));
    }
View Full Code Here

    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void delete_jpaObject() {
        WidgetComment wc = repository.getCommentById(VALID_WIDGET_ID.toString(), VALID_WIDGET_COMMENT_ID.toString());
        assertThat(wc, is(notNullValue()));
        repository.deleteWidgetComment(VALID_WIDGET_ID.toString(), wc);
        wc = repository.getCommentById(VALID_WIDGET_ID.toString(), VALID_WIDGET_COMMENT_ID.toString());
        assertThat(wc, is(nullValue()));
    }
View Full Code Here

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

TOP

Related Classes of org.apache.rave.model.WidgetComment

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.