1 package net.pterodactylus.sone.freenet.wot
3 import com.google.common.eventbus.EventBus
4 import net.pterodactylus.sone.freenet.plugin.PluginException
5 import org.hamcrest.MatcherAssert.assertThat
6 import org.hamcrest.Matchers.equalTo
10 * Unit test for [IdentityManagerImpl].
12 class IdentityManagerTest {
14 private val eventBus = EventBus()
17 fun identityManagerPingsWotConnector() {
18 var pingCalled = false
19 val webOfTrustConnector = dummyWebOfTrustConnector.overridePing { Unit.also { pingCalled = true } }
20 val identityManager = IdentityManagerImpl(eventBus, webOfTrustConnector, IdentityLoader(webOfTrustConnector, Context("Test")))
21 assertThat(identityManager.isConnected, equalTo(true))
22 assertThat(pingCalled, equalTo(true))
26 fun disconnectedWotConnectorIsRecognized() {
27 val webOfTrustConnector = dummyWebOfTrustConnector.overridePing { throw PluginException() }
28 val identityManager = IdentityManagerImpl(eventBus, webOfTrustConnector, IdentityLoader(webOfTrustConnector, Context("Test")))
29 assertThat(identityManager.isConnected, equalTo(false))