X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fnotification%2FNotificationHandlerModuleTest.kt;h=ca52c1fad5573f6d6a1a09444639608440330989;hb=2ec60e8d6d2efadd7b4d35de3c3d257a0bc5f190;hp=b84b3ee3a330de7fc808e26138137a510d39de6e;hpb=439fb3dfa1ccf157388a0e0b306013d0aa46bb50;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt index b84b3ee..ca52c1f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt @@ -25,16 +25,21 @@ import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.data.Post.* import net.pterodactylus.sone.data.impl.* +import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.notify.* import net.pterodactylus.sone.test.* import net.pterodactylus.sone.utils.* import net.pterodactylus.util.notify.* import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers import org.hamcrest.Matchers.* +import org.mockito.* import org.mockito.Mockito.* import java.io.* import java.util.concurrent.* +import java.util.concurrent.TimeUnit.* +import java.util.function.* import kotlin.test.* /** @@ -43,6 +48,7 @@ import kotlin.test.* class NotificationHandlerModuleTest { private val core = mock() + private val webOfTrustConnector = mock() private val ticker = mock() private val notificationManager = NotificationManager() private val loaders = TestLoaders() @@ -50,6 +56,7 @@ class NotificationHandlerModuleTest { Core::class.isProvidedBy(core), NotificationManager::class.isProvidedBy(notificationManager), Loaders::class.isProvidedBy(loaders), + WebOfTrustConnector::class.isProvidedBy(webOfTrustConnector), ScheduledExecutorService::class.withNameIsProvidedBy(ticker, "notification"), NotificationHandlerModule() ) @@ -400,4 +407,54 @@ class NotificationHandlerModuleTest { injector.verifySingletonInstance() } + @Test + fun `web-of-trust notification is created as singleton`() { + injector.verifySingletonInstance(named("webOfTrust")) + } + + @Test + fun `web-of-trust notification has correct ID`() { + assertThat(injector.getInstance(named("webOfTrust")).id, equalTo("wot-missing-notification")) + } + + @Test + fun `web-of-trust notification is dismissable`() { + assertThat(injector.getInstance(named("webOfTrust")).isDismissable, equalTo(true)) + } + + @Test + fun `web-of-trust notification loads correct template`() { + loaders.templates += "/templates/notify/wotMissingNotification.html" to "1".asTemplate() + val notification = injector.getInstance(named("webOfTrust")) + assertThat(notification.render(), equalTo("1")) + } + + @Test + fun `web-of-trust handler is created as singleton`() { + injector.verifySingletonInstance(named("webOfTrust")) + } + + @Test + fun `web-of-trust reacher is created as singleton`() { + injector.verifySingletonInstance(named("webOfTrustReacher")) + } + + @Test + fun `web-of-trust reacher access the wot connector`() { + injector.getInstance(named("webOfTrustReacher")).run() + verify(webOfTrustConnector).ping() + } + + @Test + fun `web-of-trust reschedule is created as singleton`() { + injector.verifySingletonInstance>(named("webOfTrustReschedule")) + } + + @Test + fun `web-of-trust reschedule schedules at the correct delay`() { + val webOfTrustPinger = injector.getInstance() + injector.getInstance>(named("webOfTrustReschedule"))(webOfTrustPinger) + verify(ticker).schedule(ArgumentMatchers.eq(webOfTrustPinger), ArgumentMatchers.eq(15L), ArgumentMatchers.eq(SECONDS)) + } + }