projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
aefada2
)
Add test for DI constructability of GetNotificationsAjaxPage
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 25 Jan 2018 17:53:33 +0000
(18:53 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 25 Jan 2018 18:30:51 +0000
(19:30 +0100)
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt
patch
|
blob
|
history
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
(file)
--- 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 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.
*/
/**
* 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
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
(file)
--- 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.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.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
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.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
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<Any>(templateNotification))
}
assertThat(templateContext.value["notification"], equalTo<Any>(templateNotification))
}
+ @Test
+ fun `page can be created by dependency injection`() {
+ assertThat(baseInjector.getInstance<GetNotificationsAjaxPage>(), notNullValue())
+ }
+
}
}