🎨 Replace IdentityManagerTest with Kotlin version
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Oct 2019 08:51:01 +0000 (10:51 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Oct 2019 08:51:01 +0000 (10:51 +0200)
src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.java [deleted file]
src/test/java/net/pterodactylus/sone/freenet/wot/IdentityManagerTest.kt [new file with mode: 0644]

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 (file)
index 62f91b8..0000000
+++ /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 (file)
index 0000000..3768efd
--- /dev/null
@@ -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<EventBus>()
+       private val webOfTrustConnector = mock<WebOfTrustConnector>()
+       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()
+       }
+
+}