/**
- * Sone - WebOfTrustPinger.kt - Copyright © 2019 David ‘Bombe’ Roden
+ * Sone - WebOfTrustPingerTest.kt - Copyright © 2019–2020 David ‘Bombe’ Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import java.util.concurrent.atomic.*
+import java.util.function.*
import kotlin.test.*
/**
private val eventBus = EventBus()
private val webOfTrustReachable = AtomicBoolean()
- private val webOfTrustReacher: () -> Unit = { webOfTrustReachable.get().onFalse { throw PluginException() } }
+ private val webOfTrustReacher = Runnable { webOfTrustReachable.get().onFalse { throw PluginException() } }
private val rescheduled = AtomicBoolean()
- private val reschedule: () -> Unit = { rescheduled.set(true) }
+ private val reschedule: Consumer<Runnable> = Consumer { if (it == pinger) rescheduled.set(true) }
private val pinger = WebOfTrustPinger(eventBus, webOfTrustReacher, reschedule)
@Test
private class WebOfTrustAppearedCatcher(private val received: () -> Unit) {
@Subscribe
- fun webOfTrustAppeared(webOfTrustAppeared: WebOfTrustAppeared) {
+ fun webOfTrustAppeared(@Suppress("UNUSED_PARAMETER") webOfTrustAppeared: WebOfTrustAppeared) {
received()
}
}
private class WebOfTrustDisappearedCatcher(private val received: () -> Unit) {
@Subscribe
- fun webOfTrustDisappeared(webOfTrustDisappeared: WebOfTrustDisappeared) {
+ fun webOfTrustDisappeared(@Suppress("UNUSED_PARAMETER") webOfTrustDisappeared: WebOfTrustDisappeared) {
received()
}
}