From: David ‘Bombe’ Roden Date: Sun, 21 Jan 2018 10:45:45 +0000 (+0100) Subject: Add test for DI constructability of ViewPostPage X-Git-Tag: v79^2~189 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a0e1d37dac7c0dc7ca0317892f301e190fd3157c;p=Sone.git Add test for DI constructability of ViewPostPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt index d3f4540..763fc99 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt @@ -8,11 +8,12 @@ import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext import java.net.URI +import javax.inject.Inject /** * This page lets the user view a post and all its replies. */ -class ViewPostPage(template: Template, webInterface: WebInterface): +class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface): SoneTemplatePage("viewPost.html", webInterface, template, "Page.ViewPost.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt index b66f6cc..a4bd4b6 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt @@ -2,10 +2,13 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.Profile +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 org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.hamcrest.Matchers.nullValue import org.junit.Test @@ -97,4 +100,9 @@ class ViewPostPageTest: WebPageTest(::ViewPostPage) { assertThat(page.getPageTitle(freenetRequest), equalTo("This is a text that … - First M. Last - view post title")) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }