Package se.unbound.tapestry.breadcrumbs.mocks

Examples of se.unbound.tapestry.breadcrumbs.mocks.LinkMock


    private final BreadCrumbList nonDiscardingLimitedList = new BreadCrumbList(false, 2);

    @Test
    public void equalCrumbsAreOnlyAddedOnce() {
        assertEquals("size", 0, this.discardingList.size());
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page"));
        assertEquals("size", 1, this.discardingList.size());
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page"));
        assertEquals("size", 1, this.discardingList.size());
    }
View Full Code Here


        assertEquals("size", 1, this.discardingList.size());
    }

    @Test
    public void crumbsAddedBetweenEqualCrumbsArePurged() {
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page1"));
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/edit"), "page2"));
        assertEquals("size", 2, this.discardingList.size());
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page1"));
        assertEquals("size", 1, this.discardingList.size());
    }
View Full Code Here

        assertEquals("size", 1, this.discardingList.size());
    }

    @Test
    public void iteratorReturnAnIteratorOfAddedCrumbs() {
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page1"));
        this.discardingList.add(new BreadCrumbInfo("key", new LinkMock("/edit"), "page2"));

        int crumbs = 2;
        for (final BreadCrumbInfo crumb : this.discardingList) {
            crumbs--;
        }
View Full Code Here

        assertEquals("iterations left", 0, crumbs);
    }

    @Test
    public void nonDuplicteDiscardingListKeepsDuplicatesOfPages() {
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page"));

        assertEquals("size", 2, this.nonDiscardingLimitedList.size());
    }
View Full Code Here

        assertEquals("size", 2, this.nonDiscardingLimitedList.size());
    }

    @Test
    public void limitedListKeepsOnlyNewestCrumbs() {
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page1"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/edit"), "page2"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/view"), "page3"));

        assertEquals("size", 2, this.nonDiscardingLimitedList.size());
        final Iterator<BreadCrumbInfo> iterator = this.nonDiscardingLimitedList.iterator();
        assertEquals("crumb 1", "page2", iterator.next().getPageName());
        assertEquals("crumb 2", "page3", iterator.next().getPageName());
View Full Code Here

        assertEquals("crumb 2", "page3", iterator.next().getPageName());
    }

    @Test
    public void limitedListIgnoresCrumbsNotShownInTrail() {
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/index"), "page1"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/edit"), "page2"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/edit"), "page2"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("ignored"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("ignored"));
        this.nonDiscardingLimitedList.add(new BreadCrumbInfo("key", new LinkMock("/view"), "page3"));

        assertEquals("size", 2, this.nonDiscardingLimitedList.getCrumbsToDisplay().size());
        final Iterator<BreadCrumbInfo> iterator = this.nonDiscardingLimitedList.iterator();
        assertEquals("crumb 1", "page2", iterator.next().getPageName());
        assertEquals("crumb 2", "page3", iterator.next().getPageName());
View Full Code Here

        assertEquals("list size", 1, this.breadCrumbList.size());
    }

    @Test
    public void dispatcherResetsBreadCrumbListIfResetAnnotationIsPresent() throws Exception {
        this.breadCrumbList.add(new BreadCrumbInfo("edit.title", new LinkMock("/edit/2"), "Edit"));
        this.addPage("index", new IndexPageMock());
        final Request request = new RequestMock("/index/1");
        final Response response = new ResponseMock();
        this.dispatcher.dispatch(request, response);
        assertEquals("list size", 1, this.breadCrumbList.size());
View Full Code Here

    }

    @Test
    public void dispatcherDoesNotResetBreadCrumbListIfResetAnnotationHasSpecifiedPreviousPageClassAsIgnored()
            throws Exception {
        this.breadCrumbList.add(new BreadCrumbInfo("edit.title", new LinkMock("/edit/2"), "Edit"));
        this.breadCrumbList.add(new BreadCrumbInfo("group"));
        this.addPage("index", new IndexPageWithIgnoreMock());
        this.addPage("group", new GroupPageMock());
        final RequestMock request = new RequestMock("localhost", 80, "/app", "/index/1");
        final Response response = new ResponseMock();
View Full Code Here

        assertEquals("list size", 2, this.breadCrumbList.getCrumbsToDisplay().size());
    }

    @Test
    public void dispatcherResetsBreadCrumbListIfRefererIsNoValidURI() throws Exception {
        this.breadCrumbList.add(new BreadCrumbInfo("edit.title", new LinkMock("/edit/2"), "Edit"));
        this.addPage("index", new IndexPageMock());
        final RequestMock request = new RequestMock("localhost", 80, "/app", "/index/1");
        request.addHeader("Referer", "http://localhost/app/");
        final Response response = new ResponseMock();
        this.dispatcher.dispatch(request, response);
View Full Code Here

TOP

Related Classes of se.unbound.tapestry.breadcrumbs.mocks.LinkMock

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.