Package org.apache.rave.model

Examples of org.apache.rave.model.WidgetRating


    @Test
    public void deleteAll_Diff_Id(){
        String userId = "111";
        Widget widget = new WidgetImpl();
        List<Widget> widgets = Arrays.asList(widget);
        WidgetRating rating = new WidgetRatingImpl();
        rating.setUserId("222");
        widget.setRatings(Arrays.asList(rating));
        expect(template.find(query(where("ratings").elemMatch(where("userId").is(userId))))).andReturn(widgets);
        replay(template);

        int count = ratingRepository.deleteAllWidgetRatings(userId);
View Full Code Here


        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);
        replay(template);

        WidgetRating widgetRating = ratingRepository.createWidgetRating(widgetId, item);
        assertTrue(widget.getRatings().contains(item));
        assertThat(widgetRating, is(sameInstance(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

    }

    @Override
    @Transactional
    public void saveWidgetRating(String widgetId, WidgetRating rating) {
        WidgetRating existingRating = getWidgetRatingByWidgetIdAndUserId(widgetId, rating.getUserId());
        if (existingRating == null) {
            widgetRepository.createWidgetRating(widgetId, rating);
        } else {
            updateWidgetRatingScore(widgetId, existingRating, rating.getScore());
        }
View Full Code Here

    }

    @Override
    @Transactional
    public void removeWidgetRating(String widgetId, String userId) {
        WidgetRating widgetRating = widgetRepository.getWidgetRatingsByWidgetIdAndUserId(widgetId, userId);
        if (widgetRating == null) {
            return;
        }
        widgetRepository.deleteWidgetRating(widgetId, widgetRating);
    }
View Full Code Here

TOP

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

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.