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