void () { SearchListModel model = new GroupedSearchListModel(); // adding to empty ----------------------------------------------------------------------- model.addElements(Arrays.asList( new SearchEverywhereFoundElementInfo("item_2_20", 250, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_3_20", 340, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_1_20", 160, STUB_CONTRIBUTOR_1), new SearchEverywhereFoundElementInfo("item_3_30", 330, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_2_10", 280, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_1_10", 180, STUB_CONTRIBUTOR_1), new SearchEverywhereFoundElementInfo("item_2_30", 230, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_3_10", 350, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_1_30", 140, STUB_CONTRIBUTOR_1) )); List<Object> actualItems = model.getItems(); List<Object> expectedItems = Arrays.asList("item_1_10", "item_1_20", "item_1_30", "item_2_10", "item_2_20", "item_2_30", "item_3_10", "item_3_20", "item_3_30"); Assert.assertEquals("adding to empty model", expectedItems, actualItems); // "more" elements ----------------------------------------------------------------------- model.setHasMore(STUB_CONTRIBUTOR_1, true); model.setHasMore(STUB_CONTRIBUTOR_3, true); actualItems = model.getItems(); expectedItems = Arrays.asList("item_1_10", "item_1_20", "item_1_30", SearchListModel.MORE_ELEMENT, "item_2_10", "item_2_20", "item_2_30", "item_3_10", "item_3_20", "item_3_30", SearchListModel.MORE_ELEMENT); Assert.assertEquals("adding \"more\" elements", expectedItems, actualItems); // adding to existing ----------------------------------------------------------------------- model.addElements(Arrays.asList( new SearchEverywhereFoundElementInfo("item_3_03", 370, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_2_23", 250, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_1_35", 130, STUB_CONTRIBUTOR_1), new SearchEverywhereFoundElementInfo("item_2_25", 245, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_1_25", 150, STUB_CONTRIBUTOR_1), new SearchEverywhereFoundElementInfo("item_3_50", 310, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_2_40", 210, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_3_40", 320, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_2_05", 290, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_3_05", 360, STUB_CONTRIBUTOR_3) )); actualItems = model.getItems(); expectedItems = Arrays.asList("item_1_10", "item_1_20", "item_1_25", "item_1_30", "item_1_35", SearchListModel.MORE_ELEMENT, "item_2_05", "item_2_10", "item_2_20", "item_2_23", "item_2_25", "item_2_30", "item_2_40", "item_3_03", "item_3_05", "item_3_10", "item_3_20", "item_3_30", "item_3_40", "item_3_50", SearchListModel.MORE_ELEMENT); Assert.assertEquals("adding to existing elements", expectedItems, actualItems); // expiring results ----------------------------------------------------------------------- model.expireResults(); model.addElements(Arrays.asList( new SearchEverywhereFoundElementInfo("item_3_50", 310, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_1_20", 160, STUB_CONTRIBUTOR_1), new SearchEverywhereFoundElementInfo("item_3_10", 350, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_2_23", 250, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_3_30", 330, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_2_05", 290, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_2_10", 280, STUB_CONTRIBUTOR_2), new SearchEverywhereFoundElementInfo("item_1_35", 130, STUB_CONTRIBUTOR_1), new SearchEverywhereFoundElementInfo("item_3_20", 340, STUB_CONTRIBUTOR_3), new SearchEverywhereFoundElementInfo("item_1_25", 150, STUB_CONTRIBUTOR_1) )); model.setHasMore(STUB_CONTRIBUTOR_1, true); model.setHasMore(STUB_CONTRIBUTOR_2, true); actualItems = model.getItems(); expectedItems = Arrays.asList("item_1_20", "item_1_25", "item_1_35", SearchListModel.MORE_ELEMENT, "item_2_05", "item_2_10", "item_2_23", SearchListModel.MORE_ELEMENT, "item_3_10", "item_3_20", "item_3_30", "item_3_50"); Assert.assertEquals("adding to expired list", expectedItems, actualItems); // removing items ----------------------------------------------------------------------- model.removeElement("item_1_25", STUB_CONTRIBUTOR_1); model.removeElement("item_3_20", STUB_CONTRIBUTOR_3); model.removeElement("item_3_30", STUB_CONTRIBUTOR_3); model.setHasMore(STUB_CONTRIBUTOR_1, false); actualItems = model.getItems(); expectedItems = Arrays.asList("item_1_20", "item_1_35", "item_2_05", "item_2_10", "item_2_23", SearchListModel.MORE_ELEMENT, "item_3_10", "item_3_50"); Assert.assertEquals("removing items", expectedItems, actualItems); }