Convert unit test to Kotlin
[Sone.git] / src / test / java / net / pterodactylus / sone / freenet / wot / IdentityManagerTest.java
1 package net.pterodactylus.sone.freenet.wot;
2
3 import static com.google.common.base.Optional.of;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.is;
6 import static org.mockito.Mockito.doThrow;
7 import static org.mockito.Mockito.mock;
8 import static org.mockito.Mockito.verify;
9
10 import net.pterodactylus.sone.freenet.plugin.PluginException;
11
12 import com.google.common.eventbus.EventBus;
13 import org.junit.Test;
14
15 /**
16  * Unit test for {@link IdentityManagerImpl}.
17  *
18  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
19  */
20 public class IdentityManagerTest {
21
22         private final EventBus eventBus = mock(EventBus.class);
23         private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class);
24         private final IdentityManager identityManager = new IdentityManagerImpl(eventBus, webOfTrustConnector, new IdentityLoader(webOfTrustConnector, of(new Context("Test"))));
25
26         @Test
27         public void identityManagerPingsWotConnector() throws PluginException {
28                 assertThat(identityManager.isConnected(), is(true));
29                 verify(webOfTrustConnector).ping();
30         }
31
32         @Test
33         public void disconnectedWotConnectorIsRecognized() throws PluginException {
34                 doThrow(PluginException.class).when(webOfTrustConnector).ping();
35                 assertThat(identityManager.isConnected(), is(false));
36                 verify(webOfTrustConnector).ping();
37         }
38
39 }