1 package net.pterodactylus.sone.freenet.wot;
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;
9 import net.pterodactylus.sone.freenet.plugin.PluginException;
11 import com.google.common.eventbus.EventBus;
12 import org.junit.Test;
15 * Unit test for {@link IdentityManager}.
17 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
19 public class IdentityManagerTest {
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"));
26 public void identityManagerPingsWotConnector() throws PluginException {
27 assertThat(identityManager.isConnected(), is(true));
28 verify(webOfTrustConnector).ping();
32 public void disconnectedWotConnectorIsRecognized() throws PluginException {
33 doThrow(PluginException.class).when(webOfTrustConnector).ping();
34 assertThat(identityManager.isConnected(), is(false));
35 verify(webOfTrustConnector).ping();