MutableDetailCategoryModel implements IDetailCategoryProvider { public DetailCategory getDetailByCode(final String detailCode) { return this.categoryByCode.get(detailCode); } MutableDetailCategoryModel(); MutableDetailCategoryModel add(final DetailCategory category); MutableDetailCategoryModel addAll(final List<DetailCategory> categories); MutableDetailCategoryModel reset(final List<DetailCategory> categories); @Override List<DetailCategory> provide(); @Override List<DetailCategory> provideSelectables(); List<DetailCategory> getRootCategories(); List<DetailCategory> getChildCategories(final DetailCategory parent); DetailCategory getDetailByCode(final String detailCode); @Override int hashCode(); @Override boolean equals(final Object otherObject);  }
@Test public void testGetDetailByCode() { final DetailCategory parent = new DetailCategory(null, "ab", "", false, null, null); final DetailCategory childA = new DetailCategory(parent, "a", "", true, null, null); final DetailCategory subParentB = new DetailCategory(parent, "b", "", false, null, null); final DetailCategory childB1 = new DetailCategory(subParentB, "b1", "", true, null, null); final DetailCategory childB2 = new DetailCategory(subParentB, "b2", "", true, null, null); final DetailCategory standalone = new DetailCategory(null, "c", "", true, null, null); this.model.addAll(Arrays.asList(parent, childA, subParentB, childB1, childB2, standalone)); Assert.assertSame(parent, this.model.getDetailByCode("ab")); Assert.assertSame(childA, this.model.getDetailByCode("a")); Assert.assertSame(subParentB, this.model.getDetailByCode("b")); Assert.assertSame(childB1, this.model.getDetailByCode("b1")); Assert.assertSame(childB2, this.model.getDetailByCode("b2")); Assert.assertSame(standalone, this.model.getDetailByCode("c")); }