From 19486ba47204d8554c04e1355dae6c113aa1e6c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 14 Apr 2019 00:01:02 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Replace=20FreenetRequestTest=20wi?= =?utf8?q?th=20Kotlin=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/web/page/FreenetRequestTest.java | 52 ---------------------- .../sone/web/page/FreenetRequestTest.kt | 40 +++++++++++++++++ 2 files changed, 40 insertions(+), 52 deletions(-) delete mode 100644 src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java create mode 100644 src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt diff --git a/src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java b/src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java deleted file mode 100644 index f754443..0000000 --- a/src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.pterodactylus.sone.web.page; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Mockito.mock; - -import java.net.URI; -import java.net.URISyntaxException; - -import net.pterodactylus.util.web.Method; - -import freenet.clients.http.ToadletContext; -import freenet.support.api.HTTPRequest; - -import org.junit.Test; - -/** - * Unit test for {@link FreenetRequest}. - */ -public class FreenetRequestTest { - - private final URI uri = new URI("."); - private final Method method = Method.GET; - private final HTTPRequest httpRequest = mock(HTTPRequest.class); - private final ToadletContext toadletContext = mock(ToadletContext.class); - private final FreenetRequest request = new FreenetRequest(uri, method, httpRequest, toadletContext); - - @SuppressWarnings("unused") - public FreenetRequestTest() throws URISyntaxException { - } - - @Test - public void uriIsRetainedCorrectly() { - assertThat(request.getUri(), is(uri)); - } - - @Test - public void methodIsRetainedCorrectly() { - assertThat(request.getMethod(), is(method)); - } - - @Test - public void httpRequestIsRetainedCorrectly() { - assertThat(request.getHttpRequest(), is(httpRequest)); - } - - @Test - public void toadletContextIsRetainedCorrectly() { - assertThat(request.getToadletContext(), is(toadletContext)); - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt new file mode 100644 index 0000000..1e3caab --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt @@ -0,0 +1,40 @@ +package net.pterodactylus.sone.web.page + +import freenet.clients.http.* +import freenet.support.api.* +import net.pterodactylus.util.web.* +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import org.junit.* +import org.mockito.Mockito.* +import java.net.* + +class FreenetRequestTest { + + private val uri = URI(".") + private val method = Method.GET + private val httpRequest = mock(HTTPRequest::class.java) + private val toadletContext = mock(ToadletContext::class.java) + private val request = FreenetRequest(uri, method, httpRequest, toadletContext) + + @Test + fun `uri is retained correctly`() { + assertThat(request.uri, equalTo(uri)) + } + + @Test + fun `method is retained correctly`() { + assertThat(request.method, equalTo(method)) + } + + @Test + fun `http request is retained correctly`() { + assertThat(request.httpRequest, equalTo(httpRequest)) + } + + @Test + fun `toadlet context is retained correctly`() { + assertThat(request.toadletContext, equalTo(toadletContext)) + } + +} -- 2.7.4