Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.Widget


        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


    }

    // returns a trusted Widget object, either from the WidgetRepository, or the
    // cached container list
    private Widget getTrustedWidget(long widgetId, List<Widget> trustedWidgetContainer) {
        Widget widget;
        if (trustedWidgetContainer.isEmpty()) {
            widget = widgetRepository.get(widgetId);
            trustedWidgetContainer.add(widget);
        } else {
            widget = trustedWidgetContainer.get(0);
View Full Code Here

    // the model object is trusted and hasn't been modified
    private boolean isWidgetOwner(Authentication authentication, Widget widget, List<Widget> trustedWidgetContainer, boolean trustedDomainObject) {
        if (widget.getOwner() == null) {
            return false;
        }
        Widget trustedWidget;
        if (trustedDomainObject) {
            trustedWidget = widget;
        } else {
            trustedWidget = getTrustedWidget(widget.getId(), trustedWidgetContainer);
        }
        return isWidgetOwnerByUsername(authentication, trustedWidget.getOwner().getUsername());
    }
View Full Code Here

    private boolean isWidgetOwnerById(Authentication authentication, Long userId) {
        return ((User)authentication.getPrincipal()).getId().equals(userId);
    }
   
    private boolean isPublishedWidget(Widget widget, List<Widget> trustedWidgetContainer, boolean trustedDomainObject) {
        Widget trustedWidget;
        if (trustedDomainObject) {
            trustedWidget = widget;
        } else {
            trustedWidget = getTrustedWidget(widget.getId(), trustedWidgetContainer);
        }
        return WidgetStatus.PUBLISHED.equals(trustedWidget.getWidgetStatus());
    }   
View Full Code Here

    }

    @Test
    public void viewWidget() {
        Model model = new ExtendedModelMap();
        Widget w = new WidgetImpl(1L, "http://example.com/widget.xml");

        expect(widgetService.getAllWidgetStatistics(validUser.getId())).andReturn(allWidgetStatisticsMap);
        expect(tagService.getAllTags()).andReturn(new ArrayList<Tag>());
        expect(categoryService.getAll()).andReturn(new ArrayList<Category>());
        expect(widgetService.getWidget(WIDGET_ID)).andReturn(w);
View Full Code Here

    @Test
    public void startAddWidget() {
        final Model model = new ExtendedModelMap();
        final String view = controller.viewAddWidgetForm(model,REFERRER_ID);
        assertEquals("View for add widget form", ViewNames.ADD_WIDGET_FORM, view);
        final Widget widget = (Widget) model.asMap().get(ModelKeys.WIDGET);
        assertNotNull("New widget in Model", widget);
    }
View Full Code Here

        assertNotNull(model.asMap().get(ModelKeys.WIDGET));
    }

    @Test
    public void doAddWidget_invalid() {
        final Widget widget = new Widget();
        widget.setTitle("Not enough data");
        final Model model = new ExtendedModelMap();
        final BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        String view = controller.viewAddWidgetResult(widget, errors, model);
        assertTrue("Invalid widget data", errors.hasErrors());
        assertEquals(ViewNames.ADD_WIDGET_FORM, view);
View Full Code Here

        regionWidgetRepository = createMock(RegionWidgetRepository.class);
        pageLayoutRepository = createMock(PageLayoutRepository.class);
        userService = createMock(UserService.class);
        pageService = new DefaultPageService(pageRepository, regionRepository, widgetRepository, regionWidgetRepository, pageLayoutRepository, userService, defaultPageName);

        validWidget = new Widget(1L, "http://dummy.apache.org/widgets/widget.xml");
       
        targetRegion = new Region();
        targetRegion.setId(2L);
        targetRegion.setRegionWidgets(new ArrayList<RegionWidget>());
        targetRegion.getRegionWidgets().add(new RegionWidget(1L, validWidget, targetRegion, 0));
View Full Code Here

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

        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

    @Test(expected = IllegalArgumentException.class)
    public void addWidgetToPage_invalidPage() {
        long WIDGET_ID = -1L;
        expect(pageRepository.get(PAGE_ID)).andReturn(null);
        expect(widgetRepository.get(WIDGET_ID)).andReturn(new Widget());
        replay(pageRepository);
        replay(regionRepository);
        replay(widgetRepository);

        pageService.addWidgetToPage(PAGE_ID, WIDGET_ID);
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.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.