Verify that no events are sent on invalid property change
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 22 Feb 2019 05:48:50 +0000 (06:48 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 22 Feb 2019 21:15:31 +0000 (22:15 +0100)
src/test/java/net/pterodactylus/sone/core/PreferencesTest.java

index fdae222..7327abc 100644 (file)
@@ -10,6 +10,7 @@ import static org.mockito.ArgumentCaptor.forClass;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 
 import net.pterodactylus.sone.core.event.InsertionDelayChangedEvent;
@@ -50,6 +51,16 @@ public class PreferencesTest {
        }
 
        @Test
+       public void noEventIsSentWhenInvalidInsertionDelayIsSet() {
+               try {
+                       preferences.setInsertionDelay(-15);
+               } catch (IllegalArgumentException iae) {
+                       /* ignore. */
+               }
+               verify(eventBus, never()).post(any());
+       }
+
+       @Test
        public void preferencesReturnDefaultValueWhenInsertionDelayIsSetToNull() {
                preferences.setInsertionDelay(null);
                assertThat(preferences.getInsertionDelay(), is(60));