Examples of WidgetRatingImpl


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

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

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

        user = new UserImpl();
        user.setUsername(VALID_USERNAME);
        user.setId(VALID_USER_ID);
View Full Code Here

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

    }


    @Test
    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

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

    public void setWidgetRating(@PathVariable String 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());
        widgetService.saveWidgetRating(widgetId, 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.impl.WidgetRatingImpl

    private void convertRatings(Widget source, MongoDbWidget widget) {
        List<WidgetRating> ratings = source.getRatings();
        List<WidgetRating> converted = Lists.newArrayList();
        for(WidgetRating rating : ratings) {
            String id = rating.getId() == null ? generateId() : rating.getId();
            converted.add(new WidgetRatingImpl(id, rating.getUserId(), rating.getScore()));
        }
        widget.setRatings(converted);
    }
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.