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

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


    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

    @Test
    public void testValidationFailsOnDuplicateUrl() {
        final String existingUrl = "http://example.com/existing_widget.xml";

        WidgetImpl widget = new WidgetImpl();
        widget.setId("123");
        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

    }

    @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.getAllTags()).andReturn(new ArrayList<Tag>());
        expect(categoryService.getAll()).andReturn(new ArrayList<Category>());
        expect(widgetService.getWidget(WIDGET_ID)).andReturn(w);
View Full Code Here

        String searchTerm = "gAdGet";

        int offset = 0;
        int pagesize = 10;
        int totalResults = 2;
        WidgetImpl widget = new WidgetImpl();
        widget.setId("1");
        List<Widget> widgets = new ArrayList<Widget>();
        widgets.add(widget);
        SearchResult<Widget> result = new SearchResult<Widget>(widgets, totalResults);
        result.setPageSize(pagesize);
View Full Code Here

    @Test
    public void doAddWidget() {
        final String widgetUrl = "http://example.com/newwidget.xml";
        final Model model = new ExtendedModelMap();
        final WidgetImpl widget = new WidgetImpl();
        widget.setId("1");
        widget.setTitle("Widget title");
        widget.setUrl(widgetUrl);
        widget.setType("OpenSocial");
        widget.setDescription("Lorem ipsum");
        final BindingResult errors = new BeanPropertyBindingResult(widget, "widget");

        expect(widgetService.registerNewWidget(widget)).andReturn(widget);
        expect(widgetService.isRegisteredUrl(widgetUrl)).andReturn(false);
        replay(widgetService);
        String view = controller.viewAddWidgetResult(widget, errors, model,REFERRER_ID);
        verify(widgetService);

        assertEquals("redirect:/app/store/widget/" + widget.getId() +     "?referringPageId=" + REFERRER_ID, view);
        assertFalse("Valid widget data", errors.hasErrors());
    }
View Full Code Here

    @Test
    public void doAddWidget_existing() {
        final String widgetUrl = "http://example.com/existingwidget.xml";
        final Model model = new ExtendedModelMap();

        final WidgetImpl existingWidget = new WidgetImpl();
        existingWidget.setId("123");
        existingWidget.setTitle("Widget title");
        existingWidget.setUrl(widgetUrl);
        existingWidget.setType("OpenSocial");

        final WidgetImpl widget = new WidgetImpl();
        widget.setTitle("Widget title");
        widget.setUrl(widgetUrl);
        widget.setType("OpenSocial");
        final BindingResult errors = new BeanPropertyBindingResult(widget, "widget");

        expect(widgetService.isRegisteredUrl(widgetUrl)).andReturn(true);
        replay(widgetService);
        String view = controller.viewAddWidgetResult(widget, errors, model,REFERRER_ID);
View Full Code Here

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

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

    @SuppressWarnings("unchecked")
    @Test
    public void viewAdminWidgetDetail() throws Exception {
        Model model = new ExtendedModelMap();
        WidgetImpl widget = new WidgetImpl();
        final String entityId = "123";
        widget.setId(entityId);
        widget.setTitle("My widget");

        expect(service.getWidget(entityId)).andReturn(widget);
        expect(categoryService.getAll()).andReturn(categories);
        replay(service, categoryService);
        String adminWidgetDetailView = controller.viewWidgetDetail(entityId,REFERRER_ID, model);
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.