From 69bbbebbf548146b03713b398a63247e5f716c85 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 2 Dec 2019 20:44:11 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Improve=20test=20for=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt index 746eb47..286648a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt @@ -24,7 +24,6 @@ import net.pterodactylus.util.notify.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import java.io.* -import java.util.concurrent.atomic.* import kotlin.test.* /** @@ -35,8 +34,8 @@ class MarkPostKnownDuringFirstStartHandlerTest { private val eventBus = EventBus() private val notificationManager = NotificationManager() - private val markedPostAsKnown = AtomicBoolean() - private val handler = MarkPostKnownDuringFirstStartHandler(notificationManager) { if (it == post) markedPostAsKnown.set(true) } + private val markedPosts = mutableListOf() + private val handler = MarkPostKnownDuringFirstStartHandler(notificationManager) { markedPosts += it } init { eventBus.register(handler) @@ -45,7 +44,7 @@ class MarkPostKnownDuringFirstStartHandlerTest { @Test fun `post is not marked as known if not during first start`() { eventBus.post(NewPostFoundEvent(post)) - assertThat(markedPostAsKnown.get(), equalTo(false)) + assertThat(markedPosts, emptyIterable()) } @Test @@ -54,7 +53,7 @@ class MarkPostKnownDuringFirstStartHandlerTest { override fun render(writer: Writer?) = Unit }) eventBus.post(NewPostFoundEvent(post)) - assertThat(markedPostAsKnown.get(), equalTo(true)) + assertThat(markedPosts, contains(post)) } } -- 2.7.4