@Test
public void selectAvailableItem() {

    List<ItemInfo> candidates = new ArrayList<ItemInfo>();
    candidates.add(item("A", 1, 10));
    candidates.add(item("B", 11, 20));
    candidates.add(item("C", 21, 30));
    CategorySummaryOperator operator = new CategorySummaryOperatorImpl();
    ItemInfo item1 = operator.selectAvailableItem(candidates, sales(1));
    ItemInfo item5 = operator.selectAvailableItem(candidates, sales(5));
    ItemInfo item10 = operator.selectAvailableItem(candidates, sales(10));
    ItemInfo item15 = operator.selectAvailableItem(candidates, sales(11));
    ItemInfo item20 = operator.selectAvailableItem(candidates, sales(20));
    ItemInfo item30 = operator.selectAvailableItem(candidates, sales(30));
    ItemInfo item31 = operator.selectAvailableItem(candidates, sales(31));
    assertThat(item1.getCategoryCodeAsString(), is("A"));
    assertThat(item5.getCategoryCodeAsString(), is("A"));
    assertThat(item10.getCategoryCodeAsString(), is("A"));
    assertThat(item15.getCategoryCodeAsString(), is("B"));
    assertThat(item20.getCategoryCodeAsString(), is("B"));
    assertThat(item30.getCategoryCodeAsString(), is("C"));
    assertThat(item31, is(nullValue()));
}