From: David ‘Bombe’ Roden Date: Sat, 20 Jan 2018 11:07:13 +0000 (+0100) Subject: Add test for DI constructability of CreatePostPage X-Git-Tag: v79^2~227 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c2802b8888fadadf7bc322739ec466762ac2cc4a;p=Sone.git Add test for DI constructability of CreatePostPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt index 31896f7..8a1268e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt @@ -8,11 +8,12 @@ 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 /** * This page lets the user create a new [Post]. */ -class CreatePostPage(template: Template, webInterface: WebInterface): +class CreatePostPage @Inject constructor(template: Template, webInterface: WebInterface): LoggedInPage("createPost.html", template, "Page.CreatePost.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt index 3b1cc8c..dccce87 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt @@ -2,11 +2,14 @@ package net.pterodactylus.sone.web.pages import com.google.common.base.Optional.absent import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.utils.asOptional +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 @@ -88,4 +91,9 @@ class CreatePostPageTest: WebPageTest(::CreatePostPage) { } } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }