From c2c32dca6279ad6f9af68cf2cf4870d56e7c2ff9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 Feb 2019 06:48:50 +0100 Subject: [PATCH] Verify that no events are sent on invalid property change --- .../java/net/pterodactylus/sone/core/PreferencesTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/net/pterodactylus/sone/core/PreferencesTest.java b/src/test/java/net/pterodactylus/sone/core/PreferencesTest.java index fdae222..7327abc 100644 --- a/src/test/java/net/pterodactylus/sone/core/PreferencesTest.java +++ b/src/test/java/net/pterodactylus/sone/core/PreferencesTest.java @@ -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)); -- 2.7.4