From: David ‘Bombe’ Roden Date: Sat, 12 Oct 2019 08:51:01 +0000 (+0200) Subject: 🎨 Replace IdentityManagerTest with Kotlin version X-Git-Tag: v81^2~109 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2f32dc2119bcf370cc982ac21782720f35fdc034;p=Sone.git 🎨 Replace IdentityManagerTest with Kotlin version --- diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.java deleted file mode 100644 index 62f91b8..0000000 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.pterodactylus.sone.freenet.wot; - -import static com.google.common.base.Optional.of; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import net.pterodactylus.sone.freenet.plugin.PluginException; - -import com.google.common.eventbus.EventBus; -import org.junit.Test; - -/** - * Unit test for {@link IdentityManagerImpl}. - */ -public class IdentityManagerTest { - - private final EventBus eventBus = mock(EventBus.class); - private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class); - private final IdentityManager identityManager = new IdentityManagerImpl(eventBus, webOfTrustConnector, new IdentityLoader(webOfTrustConnector, new Context("Test"))); - - @Test - public void identityManagerPingsWotConnector() throws PluginException { - assertThat(identityManager.isConnected(), is(true)); - verify(webOfTrustConnector).ping(); - } - - @Test - public void disconnectedWotConnectorIsRecognized() throws PluginException { - doThrow(PluginException.class).when(webOfTrustConnector).ping(); - assertThat(identityManager.isConnected(), is(false)); - verify(webOfTrustConnector).ping(); - } - -} diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.kt b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.kt new file mode 100644 index 0000000..3768efd --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.kt @@ -0,0 +1,33 @@ +package net.pterodactylus.sone.freenet.wot + +import com.google.common.eventbus.* +import net.pterodactylus.sone.freenet.plugin.* +import net.pterodactylus.sone.test.* +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import org.junit.* +import org.mockito.Mockito.* + +/** + * Unit test for [IdentityManagerImpl]. + */ +class IdentityManagerTest { + + private val eventBus = mock() + private val webOfTrustConnector = mock() + private val identityManager = IdentityManagerImpl(eventBus, webOfTrustConnector, IdentityLoader(webOfTrustConnector, Context("Test"))) + + @Test + fun identityManagerPingsWotConnector() { + assertThat(identityManager.isConnected, equalTo(true)) + verify(webOfTrustConnector).ping() + } + + @Test + fun disconnectedWotConnectorIsRecognized() { + doThrow(PluginException::class.java).whenever(webOfTrustConnector).ping() + assertThat(identityManager.isConnected, equalTo(false)) + verify(webOfTrustConnector).ping() + } + +}