Package org.apache.rave.portal.model

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


        WidgetImpl w = new WidgetImpl();
        w.setId(WIDGET_ID);
        w.setType(Constants.WIDGET_TYPE);
        w.setUrl(VALID_GADGET_URL);
        Region region = new RegionImpl(REGION_ID);
        RegionWidget rw = new RegionWidgetImpl();
        rw.setId(REGION_WIDGET_ID);
        rw.setCollapsed(VALID_COLLAPSED);
        rw.setWidget(w);
        rw.setRegion(region);
        rw.setHideChrome(VALID_HIDE_CHROME);
        rw.setLocked(VALID_LOCKED);
        rw.setPreferences(Arrays.asList((RegionWidgetPreference)new RegionWidgetPreferenceImpl( 1L, "color", "blue"),
                                        new RegionWidgetPreferenceImpl(1L, "speed", "fast"),
                                        new RegionWidgetPreferenceImpl( 1L, null, null)));

        final String markup =
            "<script>rave.registerWidget(" + REGION_ID + ", {type: 'OpenSocial'," +
            " regionWidgetId: " + REGION_WIDGET_ID + "," +
            " widgetUrl: '" + VALID_GADGET_URL +"', " +
            " securityToken: '" + VALID_SECURITY_TOKEN + "', " +
            " metadata: " + VALID_METADATA + "," +
            " userPrefs: {\"speed\":\"fast\",\"color\":\"blue\"}," +
            " collapsed: " + VALID_COLLAPSED + ", " +
            " widgetId: " + WIDGET_ID + "," +
            " locked: " + VALID_LOCKED + "," +
            " hideChrome: " + VALID_HIDE_CHROME +
            "});</script>";

        expect(securityTokenService.getEncryptedSecurityToken(rw)).andReturn(VALID_SECURITY_TOKEN);
        replay(securityTokenService);

        String key = OpenSocialWidgetRenderer.REGISTER_WIDGET_KEY+"-"+rw.getId();
        scriptManager.registerScriptBlock(key, markup, ScriptLocation.AFTER_RAVE, RenderScope.CURRENT_REQUEST, renderContext);
        expectLastCall();
        replay(scriptManager);

        String result = renderer.render(rw, renderContext);

        assertThat(result, is(equalTo("<!-- RegionWidget " + rw.getId() + " placeholder -->")));
        verify(scriptManager);
    }
View Full Code Here


    @Test
    public void render_null() {
        WidgetImpl w = new WidgetImpl();
        w.setType(Constants.WIDGET_TYPE);
        Region region = new RegionImpl(1L);
        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidget(w);
        rw.setRegion(region);

        final String markup =
            "<script>rave.registerWidget(1, {type: 'OpenSocial'," +
            " regionWidgetId: null," +
            " widgetUrl: 'null', " +
View Full Code Here

    @Test(expected = NotSupportedException.class)
    public void render_invalid() {
        WidgetImpl w = new WidgetImpl();
        w.setType("NONE");
        w.setUrl("http://www.example.com/gadget.xml");
        RegionWidget rw = new RegionWidgetImpl();
        rw.setId(1L);
        rw.setWidget(w);

        renderer.render(rw, null);
    }
View Full Code Here

       
        W3CWidget w = new W3CWidget();
        w.setType(Constants.WIDGET_TYPE);
        w.setUrl("http://example.com/widgets/1");
        Region region = new RegionImpl(REGION_ID);
        RegionWidget rw = new RegionWidgetImpl();
        rw.setId(REGION_WIDGET_ID);
        rw.setWidget(w);
        rw.setRegion(region);

        W3CWidget wookieWidget = new W3CWidget();
        wookieWidget.setUrl(VALID_WIDGET_INSTANCE_URL);

        expect(wookieService.getWidget(eq(user), eq(rw.getId().toString()), isA(Widget.class))).andReturn(wookieWidget);
        replay(wookieService);

        String placeholder = renderer.render(rw, renderContext);
        assertEquals("Script block for widget is incorrect", "<!-- RegionWidget " + REGION_WIDGET_ID + " placeholder -->", placeholder);
    }
View Full Code Here

    @Test(expected = NotSupportedException.class)
    public void render_invalid() {
        Widget w = new WidgetImpl();
        w.setType("NONE");
        w.setUrl(VALID_WIDGET_URL);
        RegionWidget rw = new RegionWidgetImpl();
        rw.setId(1L);
        rw.setWidget(w);

        RenderContext renderContext = createNiceMock(RenderContext.class);
        renderer.render(rw, renderContext);
    }
View Full Code Here

        assertEquals(repository.getType(), JpaRegionWidget.class);
    }

    @Test
    public void getById_validId() {
        RegionWidget regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        assertThat(regionWidget, is(notNullValue()));
        assertThat(regionWidget.getId(), is(equalTo(VALID_REGION_WIDGET_ID)));
    }
View Full Code Here

        assertThat(regionWidget.getId(), is(equalTo(VALID_REGION_WIDGET_ID)));
    }

    @Test
    public void getById_invalidId() {
        RegionWidget regionWidget = repository.get(INVALID_REGION_WIDGET_ID);
        assertThat(regionWidget, is(nullValue()));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_newEntity() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        assertThat(saved, is(sameInstance(regionWidget)));
        assertThat(saved.getId(), is(notNullValue()));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_existingEntity() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setId(VALID_REGION_WIDGET_ID);
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        assertThat(saved, is(not(sameInstance(regionWidget))));
        assertThat(saved.getId(), is(equalTo(regionWidget.getId())));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        RegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(null, null, VALID_PREFERENCE_NAME,
                VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();

        assertThat(saved.getPreferences().size(), is(equalTo(1)));
        JpaRegionWidgetPreference actual = (JpaRegionWidgetPreference)saved.getPreferences().get(0);

        assertThat(actual, is(sameInstance(regionWidgetPreference)));
        assertThat(actual.getEntityId(), is(notNullValue()));
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.RegionWidget

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.