Examples of WidgetRatingImpl


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

        service = new DefaultWidgetRatingService(repository);
    }

    @Test
    public void testGetByWidgetIdAndUserId() {
        WidgetRating widgetRating = new WidgetRatingImpl(1L, 2L, 3L, 5);
        expect(repository.getByWidgetIdAndUserId(2L, 3L)).andReturn(widgetRating);
        replay(repository);
        final WidgetRating rating = service.getByWidgetIdAndUserId(2L, 3L);
        assertEquals("Score is 5", Integer.valueOf(5), rating.getScore());
        verify(repository);
View Full Code Here

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

        verify(repository, widgetRating);
    }

    @Test
    public void saveWidgetRating_new() {
        WidgetRating newRating = new WidgetRatingImpl();
        newRating.setWidgetId(2L);
        newRating.setUserId(1L);
        newRating.setScore(10);

        expect(repository.getByWidgetIdAndUserId(2L, 1L)).andReturn(null);
        expect(repository.save(newRating)).andReturn(newRating);
        replay(repository);
View Full Code Here

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

        verify(repository);
    }

    @Test
    public void saveWidgetRating_existing() {
        WidgetRating existingRating = new WidgetRatingImpl(1L, 1L, 1L, 5);
        WidgetRating newRating = new WidgetRatingImpl();
        newRating.setWidgetId(1L);
        newRating.setUserId(1L);
        newRating.setScore(10);

        expect(repository.getByWidgetIdAndUserId(1L, 1L)).andReturn(existingRating);
        expect(repository.save(existingRating)).andReturn(existingRating);
        replay(repository);
View Full Code Here

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

        assertEquals("Updated score", Integer.valueOf(10), existingRating.getScore());
    }

    @Test
    public void removeWidgetRating_existingRating() {
        final WidgetRating widgetRating = new WidgetRatingImpl(1L, 1L, 1L, 5);

        expect(repository.getByWidgetIdAndUserId(1L, 1L)).andReturn(widgetRating);
        repository.delete(widgetRating);
        expectLastCall();
        replay(repository);
View Full Code Here

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

        String userId = "1234L";
        Map<String, WidgetRating> wr = Maps.newHashMap();
        List<Widget> widgets = Lists.newArrayList();
        List<WidgetRating> widget_ratings = Lists.newArrayList();
        Widget widget = new WidgetImpl("1111L");
        WidgetRating rating1 = new WidgetRatingImpl();
        WidgetRating rating2 = new WidgetRatingImpl();
        rating1.setUserId(userId);
        rating2.setUserId("5555L");
        widget_ratings.add(rating1);
        widget_ratings.add(rating2);
        widget.setRatings(widget_ratings);
        widgets.add(widget);
        Query q = query(where("ratings").elemMatch(where("userId").is(userId)));
View Full Code Here

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

    @Test
    public void getByWidgetIdAndUserId_Valid(){
        String widgetId = "222";
        String userId = "333";
        Widget widget = new WidgetImpl();
        WidgetRating widgetRating = new WidgetRatingImpl();
        widgetRating.setUserId(userId);
        widget.setRatings(Arrays.asList(widgetRating));
        expect(template.get(widgetId)).andReturn(widget);
        replay(template);
        assertThat(ratingRepository.getWidgetRatingsByWidgetIdAndUserId(widgetId, userId), is(sameInstance(widgetRating)));
    }
View Full Code Here

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

    @Test
    public void getByWidgetIdAndUserId_Diff_Id(){
        String widgetId = "222";
        String userId = "333";
        Widget widget = new WidgetImpl();
        WidgetRating widgetRating = new WidgetRatingImpl();
        widgetRating.setUserId("444");
        widget.setRatings(Arrays.asList(widgetRating));
        expect(template.get(widgetId)).andReturn(widget);
        replay(template);
        assertNull(ratingRepository.getWidgetRatingsByWidgetIdAndUserId(widgetId, userId));
    }
View Full Code Here

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

    @Test
    public void deleteAll_Valid(){
        String userId = "233";
        List<Widget> widgets = new ArrayList<Widget>();
        Widget delete = new WidgetImpl();
        WidgetRating rating = new WidgetRatingImpl();
        List<WidgetRating> ratings= new ArrayList<WidgetRating>();
        ratings.add(rating);
        delete.setRatings(ratings);
        rating.setUserId(userId);
        widgets.add(delete);
        expect(template.find(query(where("ratings").elemMatch(where("userId").is(userId))))).andReturn(widgets);
        expect(template.save(delete)).andReturn(null);
        replay(template);
View Full Code Here

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

    @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

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

    @Test
    public void get_Valid(){
        String id = "342";
        String widgetId = "243";
        Widget found = new WidgetImpl(widgetId);
        WidgetRatingImpl widgetRating = new WidgetRatingImpl();
        widgetRating.setId(id);
        found.setRatings(Arrays.asList((WidgetRating) widgetRating));
        expect(template.get(widgetId)).andReturn(found);
        replay(template);

        assertThat(ratingRepository.getRatingById(widgetId, id), is(sameInstance((WidgetRating)widgetRating)));
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.