### Question:
BeanItemContainer extends
        AbstractBeanContainer<BEANTYPE, BEANTYPE> { @Override public void addAll(Collection<? extends BEANTYPE> collection) { super.addAll(collection); } BeanItemContainer(Class<? super BEANTYPE> type); @SuppressWarnings("unchecked") @Deprecated  BeanItemContainer(Collection<? extends BEANTYPE> collection);  BeanItemContainer(Class<? super BEANTYPE> type,
            Collection<? extends BEANTYPE> collection); @Override void addAll(Collection<? extends BEANTYPE> collection); @Override @SuppressWarnings("unchecked") BeanItem<BEANTYPE> addItemAfter(Object previousItemId,
            Object newItemId); @Override @SuppressWarnings("unchecked") BeanItem<BEANTYPE> addItemAt(int index, Object newItemId); @Override @SuppressWarnings("unchecked") BeanItem<BEANTYPE> addItem(Object itemId); @Override BeanItem<BEANTYPE> addBean(BEANTYPE bean);  }### Answer:
@Test public void testAddAll() { BeanItemContainer<Person> container = new BeanItemContainer<Person>( Person.class); Person john = new Person("John"); Person jane = new Person("Jane"); Person matthew = new Person("Matthew"); container.addBean(john); container.addBean(jane); container.addBean(matthew); assertEquals(3, container.size()); Person jack = new Person("Jack"); Person michael = new Person("Michael"); container.addAll(Arrays.asList(jack, michael)); assertEquals(5, container.size()); assertEquals(jane, container.nextItemId(john)); assertEquals(matthew, container.nextItemId(jane)); assertEquals(jack, container.nextItemId(matthew)); assertEquals(michael, container.nextItemId(jack)); }
@Test public void testItemAddedEvent_amountOfAddedItems() { BeanItemContainer<Person> container = new BeanItemContainer<Person>( Person.class); ItemSetChangeListener addListener = createListenerMockFor(container); Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener); EasyMock.replay(addListener); List<Person> beans = Arrays.asList(new Person("Jack"), new Person( "John")); container.addAll(beans); assertEquals(2, capturedEvent.getValue().getAddedItemsCount()); }
@Test public void testItemAddedEvent_someItemsAreFiltered_amountOfAddedItemsIsReducedByAmountOfFilteredItems() { BeanItemContainer<Person> container = new BeanItemContainer<Person>( Person.class); ItemSetChangeListener addListener = createListenerMockFor(container); Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener); EasyMock.replay(addListener); List<Person> beans = Arrays.asList(new Person("Jack"), new Person( "John")); container.addFilter(new Compare.Equal("name", "John")); container.addAll(beans); assertEquals(1, capturedEvent.getValue().getAddedItemsCount()); }
@Test public void testItemAddedEvent_someItemsAreFiltered_addedItemIsTheFirstVisibleItem() { BeanItemContainer<Person> container = new BeanItemContainer<Person>( Person.class); Person bean = new Person("John"); ItemSetChangeListener addListener = createListenerMockFor(container); Capture<ItemAddEvent> capturedEvent = captureAddEvent(addListener); EasyMock.replay(addListener); List<Person> beans = Arrays.asList(new Person("Jack"), bean); container.addFilter(new Compare.Equal("name", "John")); container.addAll(beans); assertEquals(bean, capturedEvent.getValue().getFirstItemId()); }