From 4371e6b5ac593304f9a4183501ba212e4c1dfa61 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 20 Jan 2018 10:43:52 +0100 Subject: [PATCH] Add test for DI constructability of BookmarksPage --- src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt | 3 ++- .../kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt index d138263..3411164 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt @@ -6,11 +6,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 /** * Page that lets the user browse all his bookmarked posts. */ -class BookmarksPage(template: Template, webInterface: WebInterface) : +class BookmarksPage @Inject constructor(template: Template, webInterface: WebInterface) : SoneTemplatePage("bookmarks.html", webInterface, template, "Page.Bookmarks.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt index e853199..a488e25 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt @@ -1,12 +1,15 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Post +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.sone.utils.Pagination +import net.pterodactylus.sone.web.baseInjector import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Before import org.junit.Test @@ -56,4 +59,9 @@ class BookmarksPageTest: WebPageTest(::BookmarksPage) { } } + @Test + fun `bookmarks page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4