From a0e1d37dac7c0dc7ca0317892f301e190fd3157c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 21 Jan 2018 11:45:45 +0100 Subject: [PATCH] Add test for DI constructability of ViewPostPage --- src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt | 3 ++- .../kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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()) + } + } -- 2.7.4