From 2f32dc2119bcf370cc982ac21782720f35fdc034 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Oct 2019 10:51:01 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Replace=20IdentityManagerTest=20w?= =?utf8?q?ith=20Kotlin=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/freenet/wot/IdentityManagerTest.java | 37 ---------------------- .../sone/freenet/wot/IdentityManagerTest.kt | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 37 deletions(-) delete mode 100644 src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.java create mode 100644 src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.kt 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() + } + +} -- 2.7.4