Package org.apache.rave.portal.model

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


    }

    @Test
    public void testNoConversion() {
        JpaWidgetRating template = new JpaWidgetRating();
        assertThat(converter.convert(template, "1"), is(sameInstance(template)));
    }
View Full Code Here


    public void convertValid() {
        WidgetRating template = new WidgetRatingImpl("1");
        template.setScore(1);
        template.setUserId("42");
       
        JpaWidgetRating jpaTemplate = converter.convert(template, "24");

        assertThat(jpaTemplate, is(not(sameInstance(template))));
        assertThat(jpaTemplate, is(instanceOf(JpaWidgetRating.class)));
        assertThat(jpaTemplate.getScore(), is(equalTo(template.getScore())));
        assertThat(jpaTemplate.getUserId(), is(equalTo(template.getUserId())));
    }
View Full Code Here

    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_new() {
        final int EXPECTED_SCORE = 1;

        WidgetRating wr = new JpaWidgetRating();
        wr.setScore(EXPECTED_SCORE);
        wr.setUserId(VALID_USER_ID);
        assertThat(wr.getId(), is(nullValue()));
        repository.createWidgetRating(VALID_WIDGET_ID, wr);
        String newId = wr.getId();
        assertThat(Long.parseLong(newId) > 0, is(true));
        WidgetRating newRating = repository.getRatingById(VALID_WIDGET_ID, newId);
        assertThat(newRating.getScore(), is(EXPECTED_SCORE));
        assertThat(newRating.getUserId(), is(VALID_USER_ID));
    }
View Full Code Here

    public JpaWidgetRating convert(WidgetRating source, String widgetId) {
        return source instanceof JpaWidgetRating ? (JpaWidgetRating) source : createEntity(source, widgetId);
    }

    private JpaWidgetRating createEntity(WidgetRating source, String widgetId) {
        JpaWidgetRating converted = null;
        if(source != null) {
            converted = new JpaWidgetRating();
            updateProperties(source, converted, widgetId);
        }
        return converted;
    }
View Full Code Here

    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_new() {
        final int EXPECTED_SCORE = 1;

        WidgetRating wr = new JpaWidgetRating();
        wr.setScore(EXPECTED_SCORE);
        wr.setUserId(VALID_USER_ID);
        wr.setWidgetId(VALID_WIDGET_ID);
        assertThat(wr.getId(), is(nullValue()));
        repository.save(wr);
        long newId = wr.getId();
        assertThat(newId > 0, is(true));
        WidgetRating newRating = repository.get(newId);
        assertThat(newRating.getScore(), is(EXPECTED_SCORE));
        assertThat(newRating.getUserId(), is(VALID_USER_ID));
        assertThat(newRating.getWidgetId(), is(VALID_WIDGET_ID));
View Full Code Here

        return manager.find(JpaWidgetRating.class, id);
    }

    @Override
    public WidgetRating save(WidgetRating item) {
        JpaWidgetRating jpaItem = converter.convert(item);
        return saveOrUpdate(jpaItem.getEntityId(), manager, jpaItem);
    }
View Full Code Here

    }

    @Test
    public void testNoConversion() {
        JpaWidgetRating template = new JpaWidgetRating();
        assertThat(converter.convert(template), is(sameInstance(template)));
    }
View Full Code Here

        WidgetRating template = new WidgetRatingImpl();
        template.setScore(1);
        template.setUserId(42L);
        template.setWidgetId(24L);
       
        JpaWidgetRating jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
        assertThat(jpaTemplate, is(instanceOf(JpaWidgetRating.class)));
        assertThat(jpaTemplate.getScore(), is(equalTo(template.getScore())));
        assertThat(jpaTemplate.getUserId(), is(equalTo(template.getUserId())));
        assertThat(jpaTemplate.getWidgetId(), is(equalTo(template.getWidgetId())));
    }
View Full Code Here

    public JpaWidgetRating convert(WidgetRating source) {
        return source instanceof JpaWidgetRating ? (JpaWidgetRating) source : createEntity(source);
    }

    private JpaWidgetRating createEntity(WidgetRating source) {
        JpaWidgetRating converted = null;
        if(source != null) {
            converted = new JpaWidgetRating();
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_new() {
        final int EXPECTED_SCORE = 1;

        WidgetRating wr = new JpaWidgetRating();
        wr.setScore(EXPECTED_SCORE);
        wr.setUserId(VALID_USER_ID);
        assertThat(wr.getId(), is(nullValue()));
        repository.createWidgetRating(VALID_WIDGET_ID, wr);
        String newId = wr.getId();
        assertThat(Long.parseLong(newId) > 0, is(true));
        WidgetRating newRating = repository.getRatingById(VALID_WIDGET_ID, newId);
        assertThat(newRating.getScore(), is(EXPECTED_SCORE));
        assertThat(newRating.getUserId(), is(VALID_USER_ID));
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.JpaWidgetRating

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.