@Test
    void testSegment() {
        AndSegmentItem as = new AndSegmentItem("farmyards", false, false);
        assertFalse(as.isLocked());
        WordItem firstItem = new WordItem("nalle");
        as.addItem(firstItem);
        WordItem item = new WordItem("bamse");
        as.addItem(1, item);
        assertTrue(as.removeItem(item));
        assertFalse(as.isFromUser());
        as.setFromUser(true);
        assertTrue(as.isFromUser());
        as.lock();
        try {
            as.removeItem(firstItem);
            fail("Excpected exception");
        } catch (IllegalStateException e) {
            // success
        }
        try {
            as.addItem(new WordItem("puppy"));
            fail("Excpected exception");
        } catch (IllegalStateException e) {
            // success
        }
        try {
            as.addItem(1, new WordItem("kvalp"));
            fail("Excpected exception");
        } catch (IllegalStateException e) {
            // success
        }
    }
Check basic contracts common to "many" item implementations.

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