X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetReplyAjaxPageTest.kt;h=c59e65c915ac609f70a20cadd7a7b6b3bec46e93;hp=6010e9f444fa17908e3ddbe2c5a7200147021f0c;hb=bf509980d5097e67d1a32f6b53bef052b396137f;hpb=fe880bd95f2f1bb155e890a9ffd2dc2abc86cb37 diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt index 6010e9f..c59e65c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt @@ -8,6 +8,7 @@ import net.pterodactylus.sone.test.whenever import net.pterodactylus.sone.utils.asTemplate import net.pterodactylus.sone.web.baseInjector import net.pterodactylus.util.template.ReflectionAccessor +import net.pterodactylus.util.template.TemplateContextFactory import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.notNullValue @@ -16,10 +17,12 @@ import org.junit.Test /** * Unit test for [GetReplyAjaxPage]. */ -class GetReplyAjaxPageTest : JsonPageTest("getReply.ajax", needsFormPassword = false, - pageSupplier = { webInterface -> - GetReplyAjaxPage(webInterface, "<%core>\n<%request>\n<%reply.text>\n<%currentSone>".asTemplate()) - }) { +class GetReplyAjaxPageTest : JsonPageTest("getReply.ajax", needsFormPassword = false) { + + private val templateContextFactory = TemplateContextFactory().apply { + addAccessor(Any::class.java, ReflectionAccessor()) + } + override val page: JsonPage by lazy { GetReplyAjaxPage(webInterface, templateContextFactory, "<%core>\n<%request>\n<%reply.text>\n<%currentSone>".asTemplate()) } @Test fun `request without reply id results in invalid-reply-id`() { @@ -36,7 +39,6 @@ class GetReplyAjaxPageTest : JsonPageTest("getReply.ajax", needsFormPassword = f whenever(time).thenReturn(1000) whenever(text).thenReturn("reply text") } - webInterface.templateContextFactory.addAccessor(Any::class.java, ReflectionAccessor()) addReply(reply) addRequestParameter("reply", "reply-id") assertThatJsonIsSuccessful()