@Test public void select_deselect_getSelectedItem() { selectionModel.select(PERSON_C); Assert.assertEquals(PERSON_C, selectionModel.getSelectedItem().get()); selectionModel.deselect(PERSON_C); Assert.assertFalse(selectionModel.getSelectedItem().isPresent()); }
@Test public void reselect() { selectionModel.select(PERSON_B); selectionModel.select(PERSON_C); assertEquals(PERSON_C, selectionModel.getSelectedItem().orElse(null)); assertFalse(selectionModel.isSelected(PERSON_A)); assertFalse(selectionModel.isSelected(PERSON_B)); assertTrue(selectionModel.isSelected(PERSON_C)); assertEquals(Optional.of(PERSON_C), selectionModel.getSelectedItem()); assertEquals(Arrays.asList(PERSON_B, PERSON_C), selectionChanges); }
@Test public void selectDeselect() { selectionModel.select(PERSON_B); selectionModel.deselect(PERSON_B); assertFalse(selectionModel.getSelectedItem().isPresent()); assertFalse(selectionModel.isSelected(PERSON_A)); assertFalse(selectionModel.isSelected(PERSON_B)); assertFalse(selectionModel.isSelected(PERSON_C)); assertFalse(selectionModel.getSelectedItem().isPresent()); assertEquals(Arrays.asList(PERSON_B, null), selectionChanges); }
@Test(expected = IllegalStateException.class) public void selectionModelChanged_usingPreviousSelectionModel_throws() { grid.setSelectionMode(SelectionMode.MULTI); selectionModel.select(PERSON_A); }