From 347a8c00eca14b2428b93b15ba4fabef79a88e2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 20 Jan 2018 13:40:57 +0100 Subject: [PATCH] Add test for DI constructability of CreateSonePage --- .../kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt | 3 ++- .../kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt index 2732aac..27b5ad4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt @@ -9,11 +9,12 @@ import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext import java.util.logging.Level import java.util.logging.Logger +import javax.inject.Inject /** * The “create Sone” page lets the user create a new Sone. */ -class CreateSonePage(template: Template, webInterface: WebInterface): +class CreateSonePage @Inject constructor(template: Template, webInterface: WebInterface): SoneTemplatePage("createSone.html", webInterface, template, "Page.CreateSone.Title") { private val logger = Logger.getLogger(CreateSonePage::class.java.name) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt index 9cbf2c3..dc21d3e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt @@ -3,12 +3,15 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.freenet.wot.OwnIdentity +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever +import net.pterodactylus.sone.web.baseInjector import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test import org.mockito.ArgumentMatchers.anyString import org.mockito.Mockito.verify @@ -142,4 +145,9 @@ class CreateSonePageTest: WebPageTest(::CreateSonePage) { assertThat(page.isEnabled(toadletContext), equalTo(true)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4