🎨 Use nullable type instead of optional
[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 public class IdentityManagerTest {
19
20         private final EventBus eventBus = mock(EventBus.class);
21         private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class);
22         private final IdentityManager identityManager = new IdentityManagerImpl(eventBus, webOfTrustConnector, new IdentityLoader(webOfTrustConnector, new Context("Test")));
23
24         @Test
25         public void identityManagerPingsWotConnector() throws PluginException {
26                 assertThat(identityManager.isConnected(), is(true));
27                 verify(webOfTrustConnector).ping();
28         }
29
30         @Test
31         public void disconnectedWotConnectorIsRecognized() throws PluginException {
32                 doThrow(PluginException.class).when(webOfTrustConnector).ping();
33                 assertThat(identityManager.isConnected(), is(false));
34                 verify(webOfTrustConnector).ping();
35         }
36
37 }