package lt.inventi.wicket.component.breadcrumb;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.Before;

public class BreadcrumbsTests {

    protected WicketTester tester = new WicketTester();

    @Before
    public void setUp() {
        createSettings().install(tester.getApplication());
    }

    protected BreadcrumbsSettings createSettings() {
        return new BreadcrumbsSettings()
            .withStatefulBreadcrumbLinks()
            .withDecoratedBookmarkableLinks();
    }

    @SuppressWarnings("unchecked")
    protected Iterable<? extends String> breadcrumbTitles() {
        Component c = tester.getComponentFromLastRenderedPage("crumbs:crumbs");
        ListView<Breadcrumb> view = ((ListView<Breadcrumb>) c);
        List<String> titles = new ArrayList<String>();
        for (Breadcrumb b : view.getList()) {
            titles.add(b.getTitleModel().getObject());
        }
        return titles;
    }

    protected abstract static class AbstractBreadcrumbTestsPage extends WebPage implements IProvideTitle {
        protected AbstractBreadcrumbTestsPage() {
            super();
        }

        protected AbstractBreadcrumbTestsPage(PageParameters parameters) {
            super(parameters);
        }

        @Override
        protected void onInitialize() {
            super.onInitialize();
            add(new BreadcrumbsPanel("crumbs"));
        }

        @Override
        public IMarkupFragment getMarkup() {
            return Markup.of("<div wicket:id=\"crumbs\"></div>");
        }

        @Override
        public IModel<String> getTitle() {
            return Model.of(getClass().getSimpleName());
        }
    }
}

@@ -537,16 +537,142 @@
 efore;%0A%0A
+import lt.inventi.wicket.component.breadcrumb.collapse.DisplayedBreadcrumb;%0Aimport lt.inventi.wicket.test.FuzzyWicketTester;%0A%0A
 public c
@@ -736,16 +736,21 @@
 r = new 
+Fuzzy
 WicketTe
@@ -1239,32 +1239,41 @@
        ListView%3C
+Displayed
 Breadcrumb%3E view
@@ -1286,16 +1286,25 @@
 istView%3C
+Displayed
 Breadcru
@@ -1380,16 +1380,25 @@
    for (
+Displayed
 Breadcru
@@ -1451,21 +1451,13 @@
 d(b.
-getTitleModel
+title
 ().g

Fix breadcrumbs tests