Add test for DI constructability of CreateSonePage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 20 Jan 2018 12:40:57 +0000 (13:40 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 20 Jan 2018 12:40:57 +0000 (13:40 +0100)
src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt

index 2732aac..27b5ad4 100644 (file)
@@ -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)
index 9cbf2c3..dc21d3e 100644 (file)
@@ -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<CreateSonePage>(), notNullValue())
+       }
+
 }