From fd11fc210ae9bf29b1797301ad456b55984c844c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 11 Dec 2019 19:00:35 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Add=20convenience=20function=20for?= =?utf8?q?=20runnables?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/net/pterodactylus/sone/utils/Functions.kt | 3 +++ .../net/pterodactylus/sone/web/notification/SoneLockedHandlerTest.kt | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/utils/Functions.kt b/src/main/kotlin/net/pterodactylus/sone/utils/Functions.kt index d7fb595..99f43b6 100644 --- a/src/main/kotlin/net/pterodactylus/sone/utils/Functions.kt +++ b/src/main/kotlin/net/pterodactylus/sone/utils/Functions.kt @@ -4,3 +4,6 @@ import java.util.function.* /** Allows easy invocation of Java Consumers. */ operator fun Consumer.invoke(t: T) = accept(t) + +/** Allows easy invocation of Java Runnables. */ +operator fun Runnable.invoke() = run() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandlerTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandlerTest.kt index 86e456d..f7c185a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandlerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandlerTest.kt @@ -22,6 +22,7 @@ import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.data.impl.* import net.pterodactylus.sone.notify.* +import net.pterodactylus.sone.utils.* import net.pterodactylus.util.notify.* import net.pterodactylus.util.template.* import org.hamcrest.MatcherAssert.* @@ -62,7 +63,7 @@ class SoneLockedHandlerTest { @Test fun `notification is added to notification manager from command`() { eventBus.post(SoneLockedEvent(sone)) - executor.scheduleds.single().command.run() + executor.scheduleds.single().command() assertThat(notificationManager.notifications, contains(notification)) } @@ -91,7 +92,7 @@ class SoneLockedHandlerTest { @Test fun `unlocking sone after showing the notification will remove the sone from the notification`() { eventBus.post(SoneLockedEvent(sone)) - executor.scheduleds.single().command.run() + executor.scheduleds.single().command() eventBus.post(SoneUnlockedEvent(sone)) assertThat(notification.elements, emptyIterable()) } -- 2.7.4