🔀 Merge branch 'release/v82'
[Sone.git] / freenet / wot / IdentityManagerTest.kt
1 package net.pterodactylus.sone.freenet.wot
2
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.*
8 import org.junit.*
9 import org.mockito.Mockito.*
10
11 /**
12  * Unit test for [IdentityManagerImpl].
13  */
14 class IdentityManagerTest {
15
16         private val eventBus = mock<EventBus>()
17         private val webOfTrustConnector = mock<WebOfTrustConnector>()
18         private val identityManager = IdentityManagerImpl(eventBus, webOfTrustConnector, IdentityLoader(webOfTrustConnector, Context("Test")))
19
20         @Test
21         fun identityManagerPingsWotConnector() {
22                 assertThat(identityManager.isConnected, equalTo(true))
23                 verify(webOfTrustConnector).ping()
24         }
25
26         @Test
27         fun disconnectedWotConnectorIsRecognized() {
28                 doThrow(PluginException::class.java).whenever(webOfTrustConnector).ping()
29                 assertThat(identityManager.isConnected, equalTo(false))
30                 verify(webOfTrustConnector).ping()
31         }
32
33 }