@Test
    final void testSetAlternatives() {
        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);
        terms.add(new Alternative("1", 1.5));
        terms.add(new Alternative("2", 0.5));
        w.setAlternatives(terms);
        assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("1") && a.exactness == 1.5),
                "Could not overwrite alternative");
        assertTrue(w.getAlternatives().stream().anyMatch((a) -> a.word.equals("2") && a.exactness == 1.0),
                "Old alternative unexpectedly removed");
        assertEquals(2, w.getAlternatives().size());
        terms.add(new Alternative("3", 0.5));
        w.setAlternatives(terms);
        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