1 package net.pterodactylus.sone.freenet.wot;
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;
10 import net.pterodactylus.sone.freenet.plugin.PluginException;
12 import com.google.common.eventbus.EventBus;
13 import org.junit.Test;
16 * Unit test for {@link IdentityManagerImpl}.
18 public class IdentityManagerTest {
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")));
25 public void identityManagerPingsWotConnector() throws PluginException {
26 assertThat(identityManager.isConnected(), is(true));
27 verify(webOfTrustConnector).ping();
31 public void disconnectedWotConnectorIsRecognized() throws PluginException {
32 doThrow(PluginException.class).when(webOfTrustConnector).ping();
33 assertThat(identityManager.isConnected(), is(false));
34 verify(webOfTrustConnector).ping();