@Test
    void testLoops() {
        AndSegmentItem as = new AndSegmentItem("farmyards", false, false);
        boolean caught = false;
        try {
            as.addItem(as);
        } catch (IllegalArgumentException e) {
            caught = true;
        }
        assertTrue(caught);
        AndItem a = new AndItem();
        caught = false;
        try {
            a.addItem(a);
        } catch (IllegalArgumentException e) {
            caught = true;
        }
        assertTrue(caught);
        caught = false;
        a.addItem(as);
        try {
            as.addItem(a);
        } catch (IllegalArgumentException e) {
            caught = true;
        }
        assertTrue(caught);
        caught = false;
        a.removeItem(as);
        as.addItem(a);
        try {
            a.addItem(as);
        } catch (IllegalArgumentException e) {
            caught = true;
        }
        assertTrue(caught);
    }
Check basic contracts common to "many" item implementations.

@author Steinar Knutsen
container-search/src/test/java/com/yahoo/prelude/query/ItemsCommonStuffTestCase.java