Examples of WidgetRating


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

Examples of org.apache.rave.model.WidgetRating

        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

Examples of org.apache.rave.model.WidgetRating

        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

Examples of org.apache.rave.model.WidgetRating

        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

Examples of org.apache.rave.model.WidgetRating

        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

Examples of org.apache.rave.model.WidgetRating

        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

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

    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 WidgetRating();
        widgetRating.setScore(score);
        widgetRating.setUserId(userService.getAuthenticatedUser().getEntityId());
        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

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

   
    @Test
    public void getUserWidgetRatings() {
        Map<Long, WidgetRating> widgetRatings = repository.getUsersWidgetRatings(1L);
       
        WidgetRating gadgetOne = widgetRatings.get(1L);
        assertEquals(WidgetRating.DISLIKE, gadgetOne.getScore());
        assertEquals(new Long(1), gadgetOne.getUserId());
        assertEquals(new Long(1), gadgetOne.getEntityId());
       
        WidgetRating gadgetTwo = widgetRatings.get(2L);
        assertEquals(WidgetRating.LIKE, gadgetTwo.getScore());
        assertEquals(new Long(1), gadgetTwo.getUserId());
        assertEquals(new Long(2), gadgetTwo.getEntityId());
    }
View Full Code Here

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

   
    @Test
    public void addWidgetRating() {
        Widget widget = repository.get(3L);
        assertNotNull(widget.getRatings());
        WidgetRating widgetRating = new WidgetRating();
        widgetRating.setScore(10);
        widgetRating.setUserId(1L);
        widgetRating.setWidgetId(widget.getEntityId());
        widget.getRatings().add(widgetRating);
       
        repository.save(widget);
       
        Widget reloadedWidget = repository.get(3L);
        List<WidgetRating> widgetRatings = reloadedWidget.getRatings();
        assertNotNull(widgetRatings);
        assertEquals(1, widgetRatings.size());
        WidgetRating reloadedWidgetRating = widgetRatings.get(0);
        assertNotNull(reloadedWidgetRating);
        assertEquals(widgetRating.getScore(), reloadedWidgetRating.getScore());
        assertEquals(widgetRating.getUserId(), reloadedWidgetRating.getUserId());
        assertEquals(widget.getEntityId(), reloadedWidgetRating.getWidgetId());
    }
View Full Code Here

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

    }
   
    @Test public void updateWidgetRating() {
        Widget widget = repository.get(4L);
        assertNotNull(widget.getRatings());
        WidgetRating widgetRating = new WidgetRating();
        widgetRating.setScore(10);
        widgetRating.setUserId(1L);
        widgetRating.setWidgetId(widget.getEntityId());
        widget.getRatings().add(widgetRating);
       
        repository.save(widget);
       
        Widget reloadedWidget = repository.get(4L);
        List<WidgetRating> widgetRatings = reloadedWidget.getRatings();
        assertNotNull(widgetRatings);
        assertEquals(1, widgetRatings.size());
        WidgetRating reloadedWidgetRating = widgetRatings.get(0);
        assertNotNull(reloadedWidgetRating);
        assertEquals(widgetRating.getScore(), reloadedWidgetRating.getScore());
        assertEquals(widgetRating.getUserId(), reloadedWidgetRating.getUserId());
        assertEquals(widget.getEntityId(), reloadedWidgetRating.getWidgetId());
       
        reloadedWidgetRating.setScore(0);
       
        repository.save(reloadedWidget);
        reloadedWidget = repository.get(4L);
        widgetRatings = reloadedWidget.getRatings();
        assertNotNull(widgetRatings);
        assertEquals(1, widgetRatings.size());
        reloadedWidgetRating = widgetRatings.get(0);
        assertNotNull(reloadedWidgetRating);
        assertEquals(widgetRating.getScore(), reloadedWidgetRating.getScore());
        assertEquals(widgetRating.getUserId(), reloadedWidgetRating.getUserId());
        assertEquals(widget.getEntityId(), reloadedWidgetRating.getWidgetId());
    }
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.