Package org.apache.rave.model

Examples of org.apache.rave.model.Widget


    }

    @Test
    public void equals_Null_Id(){
        widget.setId(ID_1);
        Widget r = new MongoDbWidget();
        assertFalse(widget.equals(r));
        assertFalse(r.equals(widget));

    }
View Full Code Here


    }

    @Test
    public void equals_Valid(){
        widget.setId(ID_1);
        Widget r = new MongoDbWidget();
        ((MongoDbWidget)r).setId(ID_1);
        assertTrue(widget.equals(r));
    }
View Full Code Here

    }

    @Test
    public void equals_Null(){
        widget.setId(null);
        Widget r = new MongoDbWidget();
        ((MongoDbWidget)r).setId(null);
        assertTrue(widget.equals(r));
    }
View Full Code Here

        this.widgetService = widgetService;
    }

    @Override
    protected final void validateIfWidgetAlreadyExists(Widget widget, Errors errors) {
        Widget existing = widgetService.getWidgetByUrl(widget.getUrl());
        if (existing == null || existing.getId().equals(widget.getId())) {
            return;
        }
        errors.rejectValue(FIELD_URL, "widget.url.exists");
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public void validate(Object target, Errors errors) {
        Widget widget = (Widget) target;

        validateRequiredFields(errors);
        validateIfWidgetAlreadyExists(widget, errors);
        validateUrlFields(widget, errors);
    }
View Full Code Here

        List<Person> friendsUsingWidget = new ArrayList<Person>();

        TypedQuery<JpaWidget> widgetQuery = manager.createNamedQuery(JpaWidget.WIDGET_GET_BY_URL, JpaWidget.class);
        widgetQuery.setParameter(JpaWidget.PARAM_URL, appId);
        final List<JpaWidget> resultList = widgetQuery.getResultList();
        Widget widget = getSingleResult(resultList);

        TypedQuery<JpaUser> usersQuery = manager.createNamedQuery(JpaUser.USER_GET_ALL_FOR_ADDED_WIDGET, JpaUser.class);
        usersQuery.setParameter(JpaUser.PARAM_WIDGET_ID, Long.parseLong(widget.getId()));
        List<User> widgetUsers = CollectionUtils.<User>toBaseTypedList(usersQuery.getResultList());

        List<Person> userFriends = findFriends(username);
        for (Person userFriend : userFriends) {
            for (User widgetUser : widgetUsers) {
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

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.