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

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


    @Test
    public void get_Diff_Id(){
        String widgetId="1234";
        Widget widget = new WidgetImpl(widgetId);
        String id = "555";
        WidgetRatingImpl rating = new WidgetRatingImpl();
        rating.setId("444");
        widget.setRatings(Arrays.asList((WidgetRating) rating));
        expect(template.get(widgetId)).andReturn(widget);
        replay(template);

        assertNull(ratingRepository.getRatingById(widgetId, id));
View Full Code Here


        assertNull(ratingRepository.getRatingById(widgetId, id));
    }

    @Test
    public void save_Id_Valid(){
        WidgetRatingImpl item = new WidgetRatingImpl();
        WidgetRatingImpl lookup = new WidgetRatingImpl();
        String widgetId = "2134";
        String userId = "3245";
        String id = "3245";
        int score = 838;
        item.setUserId(userId);
        item.setScore(score);
        item.setId(id);
        lookup.setId(id);
        Widget widget = new WidgetImpl();
        widget.setRatings(Arrays.asList((WidgetRating)lookup));

        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(widget);
        replay(template);

        WidgetRating widgetRating = ratingRepository.updateWidgetRating(widgetId, item);

        assertThat(item.getScore(), is(equalTo(lookup.getScore())));
        assertThat(item.getUserId(), is(equalTo(lookup.getUserId())));
        assertThat(item.getScore(), is(equalTo(lookup.getScore())));
        assertThat(widgetRating, is(sameInstance((WidgetRating)lookup)));
    }
View Full Code Here

        assertThat(widgetRating, is(sameInstance((WidgetRating)lookup)));
    }

    @Test
    public void save_Id_Null(){
        WidgetRating item = new WidgetRatingImpl();
        String widgetId = "5544";
        Widget widget = new WidgetImpl();
        widget.setRatings(new ArrayList<WidgetRating>());
        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(widget);
View Full Code Here

        assertThat(widgetRating, is(sameInstance(item)));
    }

    @Test
    public void save_Null(){
        WidgetRatingImpl item = new WidgetRatingImpl();
        Widget widget = new WidgetImpl();
        widget.setRatings(new ArrayList<WidgetRating>());
        String id = "123";
        String widgetId = "321";
        Widget saved = new WidgetImpl();
        saved.setRatings(new ArrayList<WidgetRating>());
        item.setId(id);
        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(saved);
        replay(template);

        assertNull(ratingRepository.updateWidgetRating(widgetId, item));
View Full Code Here

        assertNull(ratingRepository.updateWidgetRating(widgetId, item));
    }

    @Test
    public void save_Diff_Id(){
        WidgetRating item = new WidgetRatingImpl();
        String widgetId = "3333";
        String itemId = "123";
        ((WidgetRatingImpl)item).setId(itemId);
        Widget widget = new WidgetImpl();
        WidgetRating exist = new WidgetRatingImpl();
        ((WidgetRatingImpl)exist).setId("4444");
        widget.setRatings(Arrays.asList(exist));

        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(widget);
View Full Code Here

        assertNull(ratingRepository.updateWidgetRating(widgetId, item));
    }

    @Test
    public void delete_Valid(){
        WidgetRating item = new WidgetRatingImpl();
        String widgetId = "387383";
        String id = "234";
        ((WidgetRatingImpl)item).setId(id);
        Widget widget = new WidgetImpl();
        ArrayList<WidgetRating> ratings = new ArrayList<WidgetRating>();
View Full Code Here

        verify(template);
    }

    @Test
    public void delete_Id_Not_Equals(){
         WidgetRating item = new WidgetRatingImpl();
        String widgetId = "32323";
        ((WidgetRatingImpl)item).setId("333333");
        Widget widget = new WidgetImpl();
        WidgetRating exist = new WidgetRatingImpl();
        ((WidgetRatingImpl)exist).setId("323");
        widget.setRatings(Arrays.asList(exist));
        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(null);
        replay(template);
View Full Code Here

    public void setWidgetRating(@PathVariable long widgetId,
                                @RequestParam(value = "score") Integer score,
                                HttpServletResponse response) {
        logger.debug("POST WidgetRating received for /api/rest/widgets/{} score: {}", widgetId, score);

        WidgetRating widgetRating = new WidgetRatingImpl();
        widgetRating.setScore(score);
        widgetRating.setUserId(userService.getAuthenticatedUser().getId());
        widgetRating.setWidgetId(widgetId);
        widgetRatingService.saveWidgetRating(widgetRating);

        // send a 204 back for success since there is no content being returned
        response.setStatus(HttpStatus.NO_CONTENT.value());
    }
View Full Code Here

    }


    @Test
    public void convertValid() {
        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

    @Before
    public void setUp() {
        mockWidgetRatingRepository = createMock(WidgetRatingRepository.class);
        defaultWidgetRatingPermissionEvaluator = new DefaultWidgetRatingPermissionEvaluator(mockWidgetRatingRepository);

        widgetRating = new WidgetRatingImpl();
        widgetRating.setUserId(VALID_USER_ID);
        widgetRating.setWidgetId(VALID_WIDGET_ID);
        widgetRating.setId(VALID_WIDGET_ID);

        user = new UserImpl();
View Full Code Here

TOP

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

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.