@Test public void testCategoryInterfaceComparator() { CategoryTree c1 = new CategoryTree(); c1.setUrlPath("men"); c1.setId(1); CategoryTree c2 = new CategoryTree(); c2.setUrlPath("men/tops"); c2.setId(2); CategoryTree c3 = new CategoryTree(); c3.setUrlPath("men/tops/tanks"); c3.setId(3); CategoryTree c4 = new CategoryTree(); c4.setUrlPath("women/tops"); c4.setId(4); BreadcrumbImpl breadcrumb = new BreadcrumbImpl(); List<CategoryInterface> categories = Arrays.asList(c4, c3, c2, c1); Whitebox.setInternalState(breadcrumb, "structureDepth", 1); categories.sort(breadcrumb.getCategoryInterfaceComparator()); assertThat(categories).containsExactly(c1, c3, c2, c4); Whitebox.setInternalState(breadcrumb, "structureDepth", 2); categories.sort(breadcrumb.getCategoryInterfaceComparator()); assertThat(categories).containsExactly(c2, c4, c1, c3); Whitebox.setInternalState(breadcrumb, "structureDepth", 3); categories.sort(breadcrumb.getCategoryInterfaceComparator()); assertThat(categories).containsExactly(c3, c2, c4, c1); }
@Override public Comparator<CategoryInterface> getCategoryInterfaceComparator() { return Comparator .comparing(structureDepthKey) .thenComparing(depthKey) .reversed() .thenComparing(idKey); }
BreadcrumbImpl implements Breadcrumb { @Override public Comparator<CategoryInterface> getCategoryInterfaceComparator() { return Comparator .comparing(structureDepthKey) .thenComparing(depthKey) .reversed() .thenComparing(idKey); } }
BreadcrumbImpl implements Breadcrumb { @Override public Comparator<CategoryInterface> getCategoryInterfaceComparator() { return Comparator .comparing(structureDepthKey) .thenComparing(depthKey) .reversed() .thenComparing(idKey); }  }
BreadcrumbImpl implements Breadcrumb { @Override public Comparator<CategoryInterface> getCategoryInterfaceComparator() { return Comparator .comparing(structureDepthKey) .thenComparing(depthKey) .reversed() .thenComparing(idKey); }  @Override Collection<NavigationItem> getItems(); @Override Comparator<CategoryInterface> getCategoryInterfaceComparator(); }
BreadcrumbImpl implements Breadcrumb { @Override public Comparator<CategoryInterface> getCategoryInterfaceComparator() { return Comparator .comparing(structureDepthKey) .thenComparing(depthKey) .reversed() .thenComparing(idKey); }  @Override Collection<NavigationItem> getItems(); @Override Comparator<CategoryInterface> getCategoryInterfaceComparator();  }