From 8a0e0ee93d2f49762d87c4897a3a4de7273b3046 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Jan 2018 18:53:33 +0100 Subject: [PATCH] Add test for DI constructability of GetNotificationsAjaxPage --- .../net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt | 4 +++- .../pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt index 19cdd24..f3b370d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt @@ -10,11 +10,13 @@ import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.notify.Notification import net.pterodactylus.util.notify.TemplateNotification import java.io.StringWriter +import javax.inject.Inject /** * AJAX handler to return all current notifications. */ -class GetNotificationsAjaxPage(webInterface: WebInterface) : JsonPage("getNotifications.ajax", webInterface) { +class GetNotificationsAjaxPage @Inject constructor(webInterface: WebInterface) : + JsonPage("getNotifications.ajax", webInterface) { override val needsFormPassword = false override val requiresLogin = false diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt index 8084b65..8f67ecf 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt @@ -3,8 +3,10 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.main.SonePlugin import net.pterodactylus.sone.test.argumentCaptor import net.pterodactylus.sone.test.get +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.notify.Notification import net.pterodactylus.util.notify.TemplateNotification import net.pterodactylus.util.template.TemplateContext @@ -14,6 +16,7 @@ import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.containsInAnyOrder import org.hamcrest.Matchers.empty import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.Mockito.verify @@ -115,4 +118,9 @@ class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requi assertThat(templateContext.value["notification"], equalTo(templateNotification)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4