From: David ‘Bombe’ Roden Date: Mon, 2 Dec 2019 19:44:11 +0000 (+0100) Subject: ✅ Improve test for handler X-Git-Tag: v81^2~5^2~90 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=69bbbebbf548146b03713b398a63247e5f716c85;p=Sone.git ✅ Improve test for handler --- 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)) } }