Package org.apache.rave.model

Examples of org.apache.rave.model.Widget


        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


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

        expect(pageRepository.get(PAGE_ID)).andReturn(value);
        expect(widgetRepository.get(WIDGET_ID)).andReturn(widget);
        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
        replay(pageRepository);
        replay(regionRepository);
        replay(widgetRepository);

        RegionWidget instance = pageService.addWidgetToPage(PAGE_ID, WIDGET_ID);

        verify(pageRepository);
        verify(regionRepository);
        verify(widgetRepository);

        verifyPositions(0, instance, true);
        assertThat(originalRegion.getRegionWidgets().get(0), is(sameInstance(instance)));
        assertThat(instance.getWidgetId(), is(equalTo(widget.getId())));

    }
View Full Code Here

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

        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

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

        expect(pageRepository.get(PAGE_ID)).andReturn(value);
        expect(widgetRepository.get(WIDGET_ID)).andReturn(widget);
        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
        replay(pageRepository,regionRepository,widgetRepository);
View Full Code Here

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Widget)) return false;

        Widget that = (Widget) o;

        if (this.getId() != null ? !this.getId().equals(that.getId()) : that.getId() != null) return false;

        return true;
    }
View Full Code Here

    public RpcResult<Widget> add(@RequestParam final String url,
                                   @RequestParam final String providerType) {
        return new RpcOperation<Widget>() {
             @Override
             public Widget execute() {
                 Widget widget = null;
                 // TODO - improve info sent back to marketplace, rather then just writing to the console
                 try {
                    widget =  marketplaceService.resolveWidgetMetadata(url, providerType);
                    if(widget == null){
                        return null;
                    }
                    BeanPropertyBindingResult results = new BeanPropertyBindingResult(widget, "widget");
                    widgetValidator.validate(widget, results);
                    if (results.hasErrors()) {
                        if(results.hasFieldErrors("url") && results.getFieldError("url").toString().contains("widget.url.exists")){
                            return widgetService.getWidgetByUrl(widget.getUrl());
                        }
                        return null;
                    }
                    return marketplaceService.addWidget(widget);
                } catch (Exception e) {
View Full Code Here

    @Test
    public void deleteAll(){
        String userId = "1234L";
        List<Widget> widgets = Lists.newArrayList();
        Widget w = new WidgetImpl();
        List<WidgetComment> comments = Lists.newArrayList();
        WidgetComment wc1 = new WidgetCommentImpl();
        WidgetComment wc2 = new WidgetCommentImpl();
        wc1.setUserId(userId);
        wc2.setUserId(userId);
        comments.add(wc1);
        comments.add(wc2);
        w.setComments(comments);
        widgets.add(w);

        expect(template.find(query(where("comments").elemMatch(where("userId").is(userId))))).andReturn(widgets);
        expect(template.save(isA(Widget.class))).andReturn(w);
        expect(template.find(query(where("comments").elemMatch(where("userId").is(userId))))).andReturn(widgets);
View Full Code Here

    @Test
    public void deleteAll_zero(){
        String userId = "1234L";
        String userId_2 = "1111L";
        List<Widget> widgets = Lists.newArrayList();
        Widget w = new WidgetImpl();
        List<WidgetComment> comments = Lists.newArrayList();
        WidgetComment wc1 = new WidgetCommentImpl();
        WidgetComment wc2 = new WidgetCommentImpl();
        wc1.setUserId(userId_2);
        wc2.setUserId(userId_2);
        comments.add(wc1);
        comments.add(wc2);
        w.setComments(comments);
        widgets.add(w);

        expect(template.find(query(where("comments").elemMatch(where("userId").is(userId))))).andReturn(widgets);
        replay(template);
View Full Code Here

    @Test
    public void get(){
        String id = "1234L";
        String widgetId = "321L";
        List<WidgetComment> comments = Lists.newArrayList();
        Widget widget = new WidgetImpl(widgetId);
        WidgetComment wc = new WidgetCommentImpl(id);
        comments.add(wc);
        widget.setComments(comments);

        expect(template.get(widgetId)).andReturn(widget);
        replay(template);

        WidgetComment result = repo.getCommentById(widgetId, id);
View Full Code Here

    @Test
    public void get_null(){
        String id = "1234L";
        String widgetId = "321L";
        List<WidgetComment> comments = Lists.newArrayList();
        Widget widget = new WidgetImpl(widgetId);
        WidgetComment wc = new WidgetCommentImpl("1111L");
        comments.add(wc);
        widget.setComments(comments);

        expect(template.get(widgetId)).andReturn(widget);
        replay(template);

        WidgetComment result = repo.getCommentById(widgetId, id);
View Full Code Here

TOP

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