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

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


    }

    @Test
    public void updateWidget_valid() {
        final String widgetUrl = "http://example.com/widget";
        WidgetImpl widget = new WidgetImpl("123", widgetUrl);
        widget.setTitle("WidgetImpl title");
        widget.setType("OpenSocial");
        widget.setDescription("Lorem ipsum");
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        expect(service.getWidgetByUrl(widgetUrl)).andReturn(widget);
View Full Code Here


    }

    @Test(expected = SecurityException.class)
    public void updateWidget_wrongToken() {
        WidgetImpl widget = new WidgetImpl();
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        sessionStatus.setComplete();
View Full Code Here

        assertFalse("Can't come here", true);
    }

    @Test
    public void updateWidget_invalid() {
        WidgetImpl widget = new WidgetImpl("123", "http://broken/url");
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        String view = controller.updateWidgetDetail(widget, errors, validToken, validToken,REFERRER_ID, modelMap, sessionStatus);
View Full Code Here


    private static SearchResult<Widget> populateWidgetSearchResult() {
        List<Widget> widgetList = new ArrayList<Widget>();
        for (int i = 0; i < DEFAULT_PAGESIZE; i++) {
            WidgetImpl widget = new WidgetImpl();
            widget.setTitle("WidgetImpl " + i);
            widgetList.add(widget);
        }
        return new SearchResult<Widget>(widgetList, 25);
    }
View Full Code Here

    public void setup() {
      widgetService = createNiceMock(WookieWidgetService.class);
        wookieWidgetMetadataRepository = createNiceMock(W3CWidgetMetadataRepository.class);
        widgetMetadataResolver = new WookieWidgetMetadataResolver(widgetService);
       
        TEST_WIDGET = new WidgetImpl();
        TEST_WIDGET.setTitle("freeder");
        TEST_WIDGET.setUrl("http://wookie.apache.org/widgets/freeder");
        TEST_WIDGET.setDescription("An RSS reader widget optimised for small screens or desktop widgets.");
        TEST_WIDGET.setThumbnailUrl("http://localhost:8080/wookie/wservices/wookie.apache.org/widgets/freeder/images/icon.png");
        TEST_WIDGET.setType(TYPE);
View Full Code Here

     *
     * @param url url for the widget
     * @return
     */
    public Widget getMetadata(String url) {
        Widget widget = new WidgetImpl();
        JSONObject jsonGadget = null;
        try {
            jsonGadget = (JSONObject) new JSONTokener(gadgetMetadataRepository.getGadgetMetadata(url)).nextValue();
            if (jsonGadget != null) {
                String query = jsonGadget.getString("modulePrefs");
                if (query != null) {
                    JSONObject jsonModulePrefsObject = (JSONObject) new JSONTokener(query).nextValue();
                    if (jsonModulePrefsObject != null) {
                        widget.setTitle(parseProperty(jsonModulePrefsObject, "title"));
                        widget.setTitleUrl(parseProperty(jsonModulePrefsObject, "titleUrl"));
                        widget.setDescription(parseProperty(jsonModulePrefsObject, "description"));
                        widget.setAuthor(parseProperty(jsonModulePrefsObject, "author"));
                        widget.setAuthorEmail(parseProperty(jsonModulePrefsObject, "authorEmail"));
                        widget.setThumbnailUrl(parseProperty(jsonModulePrefsObject, "thumbnail"));
                        widget.setScreenshotUrl(parseProperty(jsonModulePrefsObject, "screenshot"));
                        widget.setUrl(url);
                        widget.setType(getSupportedContext());
                    }
                }
            }
        } catch (JSONException e) {
            try {
View Full Code Here

        assertThat(result, is(sameInstance(VALID_METADATA)));
    }

    @Test
    public void getEncryptedSecurityToken_valid() {
        Widget widget = new WidgetImpl("25", VALID_GADGET_URL);
        Page page = new PageImpl(VALID_PAGE_ID, VALID_OWNER_ID);
        widget.setWidgetStatus(WidgetStatus.PUBLISHED);
        expect(widgetService.getWidgetByUrl(VALID_GADGET_URL)).andReturn(widget);
        expect(pageService.getPage(VALID_PAGE_ID)).andReturn(page);
        expect(tokenService.getEncryptedSecurityToken(isA(RegionWidget.class), eq(widget))).andReturn(VALID_TOKEN);
        replay(widgetService, pageService, tokenService);
View Full Code Here

        assertThat(openSocialService.getEncryptedSecurityToken(VALID_PAGE_ID, VALID_GADGET_URL), is(equalTo(VALID_TOKEN)));
    }

    @Test(expected = IllegalStateException.class)
    public void getEncryptedSecurityToken_NotPublished() {
        Widget widget = new WidgetImpl("25", VALID_GADGET_URL);
        widget.setWidgetStatus(WidgetStatus.PREVIEW);
        expect(widgetService.getWidgetByUrl(VALID_GADGET_URL)).andReturn(widget);
        replay(widgetService, pageService, tokenService);

        assertThat(openSocialService.getEncryptedSecurityToken(VALID_PAGE_ID, VALID_GADGET_URL), is(equalTo(VALID_TOKEN)));
    }
View Full Code Here

        assertThat(openSocialService.getEncryptedSecurityToken(VALID_PAGE_ID, VALID_GADGET_URL), is(equalTo(VALID_TOKEN)));
    }

    @Test(expected = ResourceNotFoundException.class)
    public void getEncryptedSecurityToken_NotFound() {
        Widget widget = new WidgetImpl("25", VALID_GADGET_URL);
        widget.setWidgetStatus(WidgetStatus.PUBLISHED);
        expect(widgetService.getWidgetByUrl(VALID_GADGET_URL)).andReturn(null);
        replay(widgetService, pageService, tokenService);

        assertThat(openSocialService.getEncryptedSecurityToken(VALID_PAGE_ID, VALID_GADGET_URL), is(equalTo(VALID_TOKEN)));
    }
View Full Code Here

        userService = createMock(UserService.class);

        pageService = new DefaultPageService(pageRepository, pageTemplateRepository, regionRepository, widgetRepository, regionWidgetRepository,
                                             pageLayoutRepository, userService, defaultPageName);

        validWidget = new WidgetImpl("1", "http://dummy.apache.org/widgets/widget.xml");

        page = new PageImpl(PAGE_ID, user.getId());
        pageUser = new PageUserImpl(user.getId(), page, 1L);
        page.setMembers(new ArrayList<PageUser>());
        page.getMembers().add(pageUser);
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.