From: David ‘Bombe’ Roden Date: Sat, 20 Jan 2018 23:45:29 +0000 (+0100) Subject: Add test for DI constructability of DistrustPage X-Git-Tag: v79^2~216 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1fc003ab87ca2f5dd2d4215289f578b6177cd324;p=Sone.git Add test for DI constructability of DistrustPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt index 70755f5..c312a70 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt @@ -6,6 +6,7 @@ import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that lets the user distrust another Sone. This will assign a @@ -13,7 +14,7 @@ import net.pterodactylus.util.template.TemplateContext * * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone) */ -class DistrustPage(template: Template, webInterface: WebInterface): +class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface): LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt index 3261df6..0424476 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt @@ -1,11 +1,14 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Sone +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.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test import org.mockito.Mockito.verify @@ -54,4 +57,9 @@ class DistrustPageTest: WebPageTest(::DistrustPage) { } } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }