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

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


    @Test
    public void get(){
        String id = "1234L";
        String widgetId = "321L";
        List<WidgetComment> comments = Lists.newArrayList();
        Widget widget = new WidgetImpl(widgetId);
        WidgetComment wc = new WidgetCommentImpl(id);
        comments.add(wc);
        widget.setComments(comments);

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

        WidgetComment result = repo.getCommentById(widgetId, id);
View Full Code Here


    @Test
    public void get_null(){
        String id = "1234L";
        String widgetId = "321L";
        List<WidgetComment> comments = Lists.newArrayList();
        Widget widget = new WidgetImpl(widgetId);
        WidgetComment wc = new WidgetCommentImpl("1111L");
        comments.add(wc);
        widget.setComments(comments);

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

        WidgetComment result = repo.getCommentById(widgetId, id);
View Full Code Here

    @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

    @Test
    public void getByWidgetIdAndUserId_Null(){
        String widgetId = "222";
        String userId = "333";
        Widget widget = new WidgetImpl();
        widget.setRatings(new ArrayList<WidgetRating>());
        expect(template.get(widgetId)).andReturn(widget);
        replay(template);
        assertNull(ratingRepository.getWidgetRatingsByWidgetIdAndUserId(widgetId, userId));
    }
View Full Code Here

    @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

    @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

    }

    @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);
        assertThat(count, is(0));
View Full Code Here

    @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

    @Test
    public void get_Null(){
        String id = "123";
        String widgetId = "1234";
        Widget widget = new WidgetImpl();
        expect(template.get(widgetId)).andReturn(widget);
        replay(template);
        widget.setRatings(new ArrayList<WidgetRating>());

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

    }

    @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

TOP

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

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.