@Test
public void getAnswerShouldReflectWhichSelectionsWereMade() {

    GridMultiWidget widget = getWidget();
    assertNull(widget.getAnswer());
    List<SelectChoice> selectChoices = getSelectChoices();
    List<String> selectedValues = new ArrayList<>();
    boolean atLeastOneSelected = false;
    for (int i = 0; i < widget.selectedItems.size(); i++) {
        boolean shouldBeSelected = random.nextBoolean();
        if (shouldBeSelected) {
            widget.selectedItems.add(i);
        }
        atLeastOneSelected = atLeastOneSelected || shouldBeSelected;
        if (shouldBeSelected) {
            SelectChoice selectChoice = selectChoices.get(i);
            selectedValues.add(selectChoice.getValue());
        }
    }
    // Make sure at least one item is selected, so we're not just retesting the
    // null answer case:
    if (!atLeastOneSelected) {
        int randomIndex = Math.abs(random.nextInt()) % widget.items.size();
        widget.selectedItems.add(randomIndex);
        SelectChoice selectChoice = selectChoices.get(randomIndex);
        selectedValues.add(selectChoice.getValue());
    }
    SelectMultiData answer = (SelectMultiData) widget.getAnswer();
    @SuppressWarnings("unchecked")
    List<Selection> answerSelections = (List<Selection>) answer.getValue();
    List<String> answerValues = selectionsToValues(answerSelections);
    for (String selectedValue : selectedValues) {
        assertTrue(answerValues.contains(selectedValue));
    }
}