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

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


        user2.setUsername(VALID_USERNAME2);
        user2.setId(VALID_USER_ID2);
        page = new PageImpl();
        page.setId(VALID_PAGE_ID);
        page.setOwnerId(user.getId());
        widget = new WidgetImpl(VALID_WIDGET_ID);
        widget.setOwnerId(VALID_USER_ID);
        widget.setWidgetStatus(WidgetStatus.PUBLISHED);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
View Full Code Here


    }


    @Test
    public void convertValid() {
        WidgetImpl template = new WidgetImpl("42");
        template.setUrl("TEST_A");
        template.setType("TEST_B");
        template.setTitle("TEST_C");
        template.setTitleUrl("TEST_D");
        template.setUrl("TEST_E");
        template.setThumbnailUrl("TEST_F");
        template.setScreenshotUrl("TEST_G");
        template.setAuthor("TEST_H");
        template.setAuthorEmail("TEST_I");
        template.setDescription("TEST_J");
        template.setWidgetStatus(WidgetStatus.PUBLISHED);
        template.setComments(new ArrayList<WidgetComment>());
        template.setOwnerId("24");
        template.setDisableRendering(true);
        template.setRatings(new ArrayList<WidgetRating>());
        template.setTags(new ArrayList<WidgetTag>());
        template.setCategories(new ArrayList<Category>());
        template.setFeatured(true);

        Widget jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance((Widget)template))));
        assertThat(jpaTemplate, is(instanceOf(JpaWidget.class)));
        assertThat(jpaTemplate.getId(), is(equalTo(template.getId())));
        assertThat(jpaTemplate.getUrl(), is(equalTo(template.getUrl())));
        assertThat(jpaTemplate.getType(), is(equalTo(template.getType())));
        assertThat(jpaTemplate.getTitle(), is(equalTo(template.getTitle())));
        assertThat(jpaTemplate.getTitleUrl(), is(equalTo(template.getTitleUrl())));
        assertThat(jpaTemplate.getUrl(), is(equalTo(template.getUrl())));
        assertThat(jpaTemplate.getThumbnailUrl(), is(equalTo(template.getThumbnailUrl())));
        assertThat(jpaTemplate.getScreenshotUrl(), is(equalTo(template.getScreenshotUrl())));
        assertThat(jpaTemplate.getAuthor(), is(equalTo(template.getAuthor())));
        assertThat(jpaTemplate.getAuthorEmail(), is(equalTo(template.getAuthorEmail())));
        assertThat(jpaTemplate.getDescription(), is(equalTo(template.getDescription())));
        assertThat(jpaTemplate.getWidgetStatus(), is(equalTo(template.getWidgetStatus())));
        assertThat(jpaTemplate.getComments(), is(equalTo(template.getComments())));
        assertThat(jpaTemplate.getOwnerId(), is(equalTo(template.getOwnerId())));
        assertThat(jpaTemplate.isDisableRendering(), is(equalTo(template.isDisableRendering())));
        assertThat(jpaTemplate.getRatings(), is(equalTo(template.getRatings())));
        assertThat(jpaTemplate.getTags(), is(equalTo(template.getTags())));
        assertThat(jpaTemplate.getCategories(), is(equalTo(template.getCategories())));
        assertThat(jpaTemplate.isFeatured(), is(equalTo(template.isFeatured())));
    }
View Full Code Here

    }

    @Test
    public void doStartTag_valid() throws IOException, JspException {
        RegionWidget regionWidget = new RegionWidgetImpl();
        WidgetImpl widget = new WidgetImpl("8");
        regionWidget.setWidgetId(widget.getId());
        widget.setType(WIDGET_TYPE);

        Set<String> strings = new HashSet<String>();
        strings.add(WIDGET_TYPE);

        RegionWidgetWrapper wrapper = new RegionWidgetWrapper(widget, regionWidget);
View Full Code Here

    @Test(expected = JspException.class)
    public void doStartTag_IOException() throws JspException, IOException {

        RegionWidget regionWidget = new RegionWidgetImpl();
        WidgetImpl widget = new WidgetImpl("8");
        regionWidget.setWidgetId(widget.getId());
        widget.setType("INVALID");

        Set<String> strings = new HashSet<String>();
        strings.add(WIDGET_TYPE);

        expect(service.getSupportedWidgetTypes()).andReturn(strings);
View Full Code Here

    public void doStartTag_unsupportedWidget() throws JspException {
        replay(pageContext);

        RegionWidget regionWidget = new RegionWidgetImpl();
        Region region = new RegionImpl("25");
        WidgetImpl widget = new WidgetImpl("8");
        regionWidget.setWidgetId(widget.getId());
        regionWidget.setRegion(region);
        widget.setType("INVALID");

        Set<String> strings = new HashSet<String>();
        strings.add(WIDGET_TYPE);

        expect(service.getSupportedWidgetTypes()).andReturn(strings);
View Full Code Here

    @Test
    public void doStartTag_disabledWidget() throws IOException, JspException {
        final String DISABLED_WIDGET_MESSAGE = "THIS IS DISABLED";

        WidgetImpl widget = new WidgetImpl("8");
        widget.setType(WIDGET_TYPE);
        widget.setDisableRendering(true);
        widget.setDisableRenderingMessage(DISABLED_WIDGET_MESSAGE);

        RegionWidget regionWidget = new RegionWidgetImpl("99");
        regionWidget.setWidgetId(widget.getId());
        regionWidget.setRegion(new RegionImpl("2"));

        Set<String> strings = new HashSet<String>();
        strings.add(WIDGET_TYPE);
View Full Code Here

    private UpdateWidgetValidator widgetValidator;
    private WidgetService widgetService;

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

        expect(widgetService.getWidgetByUrl(VALID_URL)).andReturn(widget);
        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.getWidgetByUrl(existingUrl)).andReturn(widget);
        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.setDescription(VALID_DESCRIPTION);
        widget.setUrl("http:/this.is/invalid?url=true&reject=true");
        widget.setScreenshotUrl("https://///invalid/screenshot");
        widget.setThumbnailUrl("thumbnail");
        widget.setTitleUrl("titleUrl");
        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

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.