1 package net.pterodactylus.sone.freenet.wot
3 import com.google.common.eventbus.*
4 import net.pterodactylus.sone.freenet.plugin.*
5 import net.pterodactylus.sone.test.*
6 import org.hamcrest.MatcherAssert.*
7 import org.hamcrest.Matchers.*
9 import org.mockito.Mockito.*
12 * Unit test for [IdentityManagerImpl].
14 class IdentityManagerTest {
16 private val eventBus = mock<EventBus>()
17 private val webOfTrustConnector = mock<WebOfTrustConnector>()
18 private val identityManager = IdentityManagerImpl(eventBus, webOfTrustConnector, IdentityLoader(webOfTrustConnector, Context("Test")))
21 fun identityManagerPingsWotConnector() {
22 assertThat(identityManager.isConnected, equalTo(true))
23 verify(webOfTrustConnector).ping()
27 fun disconnectedWotConnectorIsRecognized() {
28 doThrow(PluginException::class.java).whenever(webOfTrustConnector).ping()
29 assertThat(identityManager.isConnected, equalTo(false))
30 verify(webOfTrustConnector).ping()