List of usage examples for org.apache.commons.lang3.mutable MutableBoolean booleanValue
public boolean booleanValue()
From source file:org.vaadin.viritin.FilterableListContainerTest.java
@Test public void clearFilters() { final List<Person> listOfPersons = getListOfPersons(100); FilterableListContainer<Person> container = new FilterableListContainer<>(listOfPersons); container.addContainerFilter(new SimpleStringFilter("firstName", "First1", true, true)); Assert.assertNotSame(listOfPersons.size(), container.size()); container.removeAllContainerFilters(); Assert.assertEquals(listOfPersons.size(), container.size()); container.addContainerFilter(new SimpleStringFilter("firstName", "foobar", true, true)); Assert.assertEquals(0, container.size()); final MutableBoolean fired = new MutableBoolean(false); container.addListener(new Container.ItemSetChangeListener() { @Override/*from w w w. j av a2s . c om*/ public void containerItemSetChange(Container.ItemSetChangeEvent event) { fired.setTrue(); } }); container.removeAllContainerFilters(); Assert.assertTrue(fired.booleanValue()); Assert.assertEquals(listOfPersons.size(), container.size()); }
From source file:org.xwiki.notifications.preferences.script.NotificationPreferenceScriptServiceTest.java
@Test public void saveNotificationPreferences() throws Exception { DocumentReference userRef = new DocumentReference("xwiki", "XWiki", "UserA"); NotificationPreferenceImpl existingPref1 = new NotificationPreferenceImpl(true, NotificationFormat.ALERT, "create"); NotificationPreferenceImpl existingPref2 = new NotificationPreferenceImpl(true, NotificationFormat.EMAIL, "update"); NotificationPreferenceImpl existingPref3 = new NotificationPreferenceImpl(false, NotificationFormat.EMAIL, "delete"); when(notificationPreferenceManager.getAllPreferences(eq(userRef))) .thenReturn(Arrays.asList(existingPref1, existingPref2, existingPref3)); final MutableBoolean isOk = new MutableBoolean(false); doAnswer(invocationOnMock -> {// www . ja v a 2 s. c o m List<NotificationPreference> prefsToSave = invocationOnMock.getArgument(0); // 1 of the preferences contained in the JSON file should be saved because the inherited preference // is the same assertEquals(9, prefsToSave.size()); assertTrue(prefsToSave.contains(existingPref1)); assertTrue(prefsToSave.contains(existingPref2)); assertFalse(prefsToSave.contains(existingPref3)); isOk.setTrue(); return true; }).when(notificationPreferenceManager).savePreferences(any(List.class)); mocker.getComponentUnderTest().saveNotificationPreferences( IOUtils.toString(getClass().getResourceAsStream("/preferences.json")), userRef); assertTrue(isOk.booleanValue()); }