Package org.apache.rave.model

Examples of org.apache.rave.model.Widget


          widget.setWidgetStatus(WidgetStatus.PREVIEW);
    }
       
        widget.setOwnerId(user.getId());

        final Widget storedWidget = widgetService.registerNewWidget(widget);
        return "redirect:/app/store/widget/" + storedWidget.getId() + "?referringPageId=" + referringPageId;
    }
View Full Code Here


        Page value = new PageImpl();
        value.setRegions(new ArrayList<Region>());
        value.getRegions().add(originalRegion);
        value.getRegions().add(targetRegion);
        Widget widget = new WidgetImpl();

        expect(pageRepository.get(PAGE_ID)).andReturn(value);
        expect(widgetRepository.get(WIDGET_ID)).andReturn(widget);
        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
        replay(pageRepository);
        replay(regionRepository);
        replay(widgetRepository);

        RegionWidget instance = pageService.addWidgetToPage(PAGE_ID, WIDGET_ID);

        verify(pageRepository);
        verify(regionRepository);
        verify(widgetRepository);

        verifyPositions(0, instance, true);
        assertThat(originalRegion.getRegionWidgets().get(0), is(sameInstance(instance)));
        assertThat(instance.getWidgetId(), is(equalTo(widget.getId())));

    }
View Full Code Here

        Page value = new PageImpl();
        value.setRegions(new ArrayList<Region>());
        value.getRegions().add(originalRegion);
        value.getRegions().add(targetRegion);
        Widget widget = new WidgetImpl();

        expect(pageRepository.get(PAGE_ID)).andReturn(value);
        expect(widgetRepository.get(WIDGET_ID)).andReturn(widget);
        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
        replay(pageRepository);
View Full Code Here

        Page value = new PageImpl();
        value.setRegions(new ArrayList<Region>());
        value.getRegions().add(originalRegion);
        value.getRegions().add(targetRegion);
        Widget widget = new WidgetImpl();

        expect(pageRepository.get(PAGE_ID)).andReturn(value);
        expect(widgetRepository.get(WIDGET_ID)).andReturn(widget);
        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
        replay(pageRepository,regionRepository,widgetRepository);
View Full Code Here

    private NewWidgetValidator widgetValidator;
    private WidgetService widgetService;

    @Test
    public void testValidateValidFormData() throws Exception {
        Widget widget = new WidgetImpl();
        widget.setTitle(VALID_TITLE);
        widget.setUrl(VALID_URL);
        widget.setType(VALID_TYPE);
        widget.setDescription(VALID_DESCRIPTION);
        Errors errors = new BindException(widget, WIDGET);

        expect(widgetService.isRegisteredUrl(VALID_URL)).andReturn(false);
        replay(widgetService);
        widgetValidator.validate(widget, errors);
View Full Code Here

        assertFalse("No validation errors", errors.hasErrors());
    }

    @Test
    public void testValidationFailsOnEmptyValues() {
        Widget widget = new WidgetImpl();
        Errors errors = new BindException(widget, WIDGET);

        widgetValidator.validate(widget, errors);

        assertEquals(4, errors.getErrorCount());
View Full Code Here

        widget.setTitle(VALID_TITLE);
        widget.setType(VALID_TYPE);
        widget.setDescription(VALID_DESCRIPTION);
        widget.setUrl(existingUrl);

        Widget newWidget = new WidgetImpl();
        newWidget.setTitle(VALID_TITLE);
        newWidget.setType(VALID_TYPE);
        newWidget.setDescription(VALID_DESCRIPTION);
        newWidget.setUrl(existingUrl);
        Errors errors = new BindException(newWidget, WIDGET);

        expect(widgetService.isRegisteredUrl(existingUrl)).andReturn(true);
        replay(widgetService);
View Full Code Here

        assertNotNull("Field error for duplicate url", errors.getFieldError("url"));
    }

    @Test
    public void testValidationFailsOnInvalidUrl() {
        Widget widget = new WidgetImpl();
        widget.setTitle(VALID_TITLE);
        widget.setType(VALID_TYPE);
        widget.setUrl("http:/this.is/invalid?url=true&reject=true");
        widget.setScreenshotUrl("https://///invalid/screenshot");
        widget.setThumbnailUrl("thumbnail");
        widget.setTitleUrl("titleUrl");
        widget.setDescription(VALID_DESCRIPTION);
        Errors errors = new BindException(widget, WIDGET);

        widgetValidator.validate(widget, errors);
        assertEquals(4, errors.getErrorCount());
        assertNotNull("Field error on url", errors.getFieldError("url"));
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 viewWidget() {
        Model model = new ExtendedModelMap();
        Widget w = new WidgetImpl("1", "http://example.com/widget.xml");

        expect(widgetService.getAllWidgetStatistics(validUser.getId())).andReturn(allWidgetStatisticsMap);
        expect(tagService.getAllTagsList()).andReturn(new ArrayList<Tag>());
        expect(categoryService.getAllList()).andReturn(new ArrayList<Category>());
        expect(widgetService.getWidget(WIDGET_ID)).andReturn(w);
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.