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
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
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
assertThat(templateContext.value["notification"], equalTo<Any>(templateNotification))
}
+ @Test
+ fun `page can be created by dependency injection`() {
+ assertThat(baseInjector.getInstance<GetNotificationsAjaxPage>(), notNullValue())
+ }
+
}