Package org.apache.rave.model

Examples of org.apache.rave.model.Widget


    }

    @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

        int score = 838;
        item.setUserId(userId);
        item.setScore(score);
        item.setId(id);
        lookup.setId(id);
        Widget widget = new WidgetImpl();
        widget.setRatings(Arrays.asList((WidgetRating)lookup));

        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(widget);
        replay(template);
View Full Code Here

    @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

    }

    @Test
    public void save_Null(){
        WidgetRatingImpl item = new WidgetRatingImpl();
        Widget widget = new WidgetImpl();
        widget.setRatings(new ArrayList<WidgetRating>());
        String id = "123";
        String widgetId = "321";
        Widget saved = new WidgetImpl();
        saved.setRatings(new ArrayList<WidgetRating>());
        item.setId(id);
        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(saved);
        replay(template);
View Full Code Here

    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);
        replay(template);
View Full Code Here

    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>();
        ratings.add(item);
        widget.setRatings(ratings);
        expect(template.get(widgetId)).andReturn(widget);
        expect(template.save(widget)).andReturn(null);
        replay(template);

        ratingRepository.deleteWidgetRating(widgetId, item);
View Full Code Here

    @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);

        ratingRepository.deleteWidgetRating(widgetId, item);
View Full Code Here

TOP

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

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.