@Test
    void testCompositeChildVerification() {
        CompositeItem root = new AndItem();
        try {
            root.addItem(null);
            fail("Expected exception");
        }
        catch (NullPointerException e) {
            assertEquals("A composite item child can not be null", e.getMessage());
        }

        try {
            root.addItem(root);
            fail("Expected exception");
        }
        catch (IllegalArgumentException e) {
            assertEquals("Attempted to add a composite to itself", e.getMessage());
        }

        try {
            OrItem child = new OrItem();
            child.addItem(root);
            root.addItem(child);
            fail("Expected exception");
        }
        catch (IllegalArgumentException e) {
            assertEquals("Cannot add 'OR (AND )' to '(AND )' as it would create a cycle", e.getMessage());
        }

        try {
            OrItem child = new OrItem();
            root.addItem(child);
            child.addItem(root);
            fail("Expected exception");
        }
        catch (IllegalArgumentException e) {
            assertEquals("Cannot add '(AND (OR ))' to '(OR )' as it would create a cycle", e.getMessage());
        }
    }
Test that we get the last value if a parameter is assigned multiple times
container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java