@Test
    final void testAddTerm() {
        List<Alternative> terms = new ArrayList<>();
        terms.add(new Alternative("1", 1.0));
        terms.add(new Alternative("2", 1.0));
        WordAlternativesItem w = new WordAlternativesItem("", true, null, terms);
        w.addTerm("1", 0.1);
        assertEquals(terms, w.getAlternatives());
        w.addTerm("1", 2.0);
        assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("1") && a.exactness == 2.0),
                "Could not add new alternative");
        assertEquals(2, w.getAlternatives().size());
        w.addTerm("3", 0.5);
        assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("3") && a.exactness == 0.5),
                "Could not add new term");
    }
Functional test for the contracts in WordAlternativesItem.

@author steinar
container-search/src/test/java/com/yahoo/prelude/query/WordAlternativesItemTestCase.java