From: David ‘Bombe’ Roden Date: Tue, 6 Dec 2016 21:18:28 +0000 (+0100) Subject: Use new redirect verification X-Git-Tag: 0.9.7^2~372 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a9c1c1770651720ec3b271464a4b490ea4a1334f;p=Sone.git Use new redirect verification --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DeleteAlbumPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DeleteAlbumPageTest.kt index d742bb6..f2e7cc5 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DeleteAlbumPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DeleteAlbumPageTest.kt @@ -4,7 +4,6 @@ import net.pterodactylus.sone.data.Album import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -25,6 +24,8 @@ class DeleteAlbumPageTest : WebPageTest() { private val album = mock() private val parentAlbum = mock() + override fun getPage() = page + @Before fun setupAlbums() { whenever(sone.id).thenReturn("sone-id") @@ -40,8 +41,7 @@ class DeleteAlbumPageTest : WebPageTest() { fun `get request with invalid album ID results in redirect to invalid page`() { request("", GET) whenever(core.getAlbum(anyString())).thenReturn(null) - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -57,8 +57,7 @@ class DeleteAlbumPageTest : WebPageTest() { @Test fun `post request redirects to invalid page if album is invalid`() { request("", POST) - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -67,8 +66,7 @@ class DeleteAlbumPageTest : WebPageTest() { whenever(sone.isLocal).thenReturn(false) addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") - expectedException.expect(redirectsTo("noPermission.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -77,8 +75,7 @@ class DeleteAlbumPageTest : WebPageTest() { addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") addHttpRequestParameter("abortDelete", "true") - expectedException.expect(redirectsTo("imageBrowser.html?album=album-id")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("imageBrowser.html?album=album-id") } @Test @@ -86,10 +83,7 @@ class DeleteAlbumPageTest : WebPageTest() { request("", POST) addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") - expectedException.expect(redirectsTo("imageBrowser.html?sone=sone-id")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("imageBrowser.html?sone=sone-id") { verify(core).deleteAlbum(album) } } @@ -100,10 +94,7 @@ class DeleteAlbumPageTest : WebPageTest() { whenever(sone.rootAlbum).thenReturn(mock()) addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") - expectedException.expect(redirectsTo("imageBrowser.html?album=parent-id")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("imageBrowser.html?album=parent-id") { verify(core).deleteAlbum(album) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DeleteImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DeleteImagePageTest.kt index 6ba4d03..d3a0b6b 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DeleteImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DeleteImagePageTest.kt @@ -5,7 +5,6 @@ import net.pterodactylus.sone.data.Image import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -13,7 +12,6 @@ import org.hamcrest.Matchers.equalTo import org.junit.Before import org.junit.Test import org.mockito.Mockito.verify -import kotlin.test.fail /** * Unit test for [DeleteImagePage]. @@ -24,6 +22,8 @@ class DeleteImagePageTest : WebPageTest() { private val image = mock() private val sone = mock() + override fun getPage() = page + @Before fun setupImage() { val album = mock() @@ -37,8 +37,7 @@ class DeleteImagePageTest : WebPageTest() { @Test fun `get request with invalid image redirects to invalid page`() { request("", GET) - expectedException.expect(redirectsTo("invalid.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -47,8 +46,7 @@ class DeleteImagePageTest : WebPageTest() { whenever(sone.isLocal).thenReturn(false) addImage("image-id", image) addHttpRequestParameter("image", "image-id") - expectedException.expect(redirectsTo("noPermission.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -66,8 +64,7 @@ class DeleteImagePageTest : WebPageTest() { addImage("image-id", image) addHttpRequestParameter("image", "image-id") addHttpRequestParameter("abortDelete", "true") - expectedException.expect(redirectsTo("imageBrowser.html?image=image-id")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("imageBrowser.html?image=image-id") } @Test @@ -75,13 +72,8 @@ class DeleteImagePageTest : WebPageTest() { request("", POST) addImage("image-id", image) addHttpRequestParameter("image", "image-id") - expectedException.expect(redirectsTo("imageBrowser.html?album=album-id")) - try { - page.processTemplate(freenetRequest, templateContext) - fail() - } catch (e: Exception) { + verifyRedirect("imageBrowser.html?album=album-id") { verify(webInterface.core).deleteImage(image) - throw e } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DeletePostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DeletePostPageTest.kt index dd42f5e..baccdfc 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DeletePostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DeletePostPageTest.kt @@ -4,7 +4,6 @@ import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -13,7 +12,6 @@ import org.junit.Before import org.junit.Test import org.mockito.Mockito.never import org.mockito.Mockito.verify -import kotlin.test.fail /** * Unit test for [DeletePostPage]. @@ -25,6 +23,8 @@ class DeletePostPageTest : WebPageTest() { private val post = mock() private val sone = mock() + override fun getPage() = page + @Before fun setupPost() { whenever(post.sone).thenReturn(sone) @@ -34,8 +34,7 @@ class DeletePostPageTest : WebPageTest() { @Test fun `get request with invalid post redirects to no permission page`() { request("", GET) - expectedException.expect(redirectsTo("noPermission.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -52,8 +51,7 @@ class DeletePostPageTest : WebPageTest() { @Test fun `post request with invalid post redirects to no permission page`() { request("", POST) - expectedException.expect(redirectsTo("noPermission.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -63,8 +61,7 @@ class DeletePostPageTest : WebPageTest() { addPost("post-id", post) addHttpRequestParameter("post", "post-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("noPermission.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -74,13 +71,8 @@ class DeletePostPageTest : WebPageTest() { addHttpRequestParameter("post", "post-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("confirmDelete", "true") - expectedException.expect(redirectsTo("return.html")) - try { - page.processTemplate(freenetRequest, templateContext) - fail() - } catch (e: Exception) { + verifyRedirect("return.html") { verify(core).deletePost(post) - throw e } } @@ -91,13 +83,8 @@ class DeletePostPageTest : WebPageTest() { addHttpRequestParameter("post", "post-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("abortDelete", "true") - expectedException.expect(redirectsTo("return.html")) - try { - page.processTemplate(freenetRequest, templateContext) - fail() - } catch (e: Exception) { + verifyRedirect("return.html") { verify(core, never()).deletePost(post) - throw e } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DeleteProfileFieldPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DeleteProfileFieldPageTest.kt index a52ac48..9966bdd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DeleteProfileFieldPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DeleteProfileFieldPageTest.kt @@ -2,7 +2,6 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -11,7 +10,6 @@ import org.hamcrest.Matchers.nullValue import org.junit.Before import org.junit.Test import org.mockito.Mockito.verify -import kotlin.test.fail /** * Unit test for [DeleteProfileFieldPage]. @@ -23,6 +21,8 @@ class DeleteProfileFieldPageTest : WebPageTest() { private val profile = Profile(currentSone) private val field = profile.addField("name") + override fun getPage() = page + @Before fun setupProfile() { whenever(currentSone.profile).thenReturn(profile) @@ -32,16 +32,14 @@ class DeleteProfileFieldPageTest : WebPageTest() { @Test fun `get request with invalid field name redirects to invalid page`() { request("", GET) - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test fun `post request with invalid field name redirects to invalid page`() { request("", POST) addHttpRequestParameter("field", "wrong-id") - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -56,8 +54,7 @@ class DeleteProfileFieldPageTest : WebPageTest() { fun `post request without confirm redirects to edit profile page`() { request("", POST) addHttpRequestParameter("field", field.id) - expectedException.expect(redirectsTo("editProfile.html#profile-fields")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("editProfile.html#profile-fields") } @Test @@ -65,14 +62,9 @@ class DeleteProfileFieldPageTest : WebPageTest() { request("", POST) addHttpRequestParameter("field", field.id) addHttpRequestParameter("confirm", "true") - expectedException.expect(redirectsTo("editProfile.html#profile-fields")) - try { - page.handleRequest(freenetRequest, templateContext) - fail() - } catch (e: Exception) { + verifyRedirect("editProfile.html#profile-fields") { assertThat(profile.getFieldById(field.id), nullValue()) verify(currentSone).profile = profile - throw e } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DeleteReplyPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DeleteReplyPageTest.kt index c2649d8..ee6de04 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DeleteReplyPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DeleteReplyPageTest.kt @@ -1,19 +1,11 @@ package net.pterodactylus.sone.web -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo -import net.pterodactylus.util.web.Method.POST -import org.mockito.ArgumentMatchers.anyInt -import org.mockito.ArgumentMatchers.eq -import org.mockito.Mockito.`when` - import net.pterodactylus.sone.data.PostReply - -import com.google.common.base.Optional import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.util.web.Method.GET -import org.hamcrest.MatcherAssert +import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.Before @@ -31,6 +23,8 @@ class DeleteReplyPageTest : WebPageTest() { private val sone = mock() private val reply = mock() + override fun getPage() = page + @Before fun setupReply() { whenever(sone.isLocal).thenReturn(true) @@ -61,8 +55,7 @@ class DeleteReplyPageTest : WebPageTest() { @Test fun `trying to delete a reply with an invalid ID results in no permission page`() { request("", POST) - expectedException.expect(redirectsTo("noPermission.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -71,8 +64,7 @@ class DeleteReplyPageTest : WebPageTest() { addHttpRequestParameter("reply", "reply-id") whenever(sone.isLocal).thenReturn(false) addPostReply("reply-id", reply) - expectedException.expect(redirectsTo("noPermission.html")) - page.processTemplate(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -82,10 +74,7 @@ class DeleteReplyPageTest : WebPageTest() { addHttpRequestParameter("reply", "reply-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("confirmDelete", "true") - expectedException.expect(redirectsTo("return.html")) - try { - page.processTemplate(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).deleteReply(reply) } } @@ -97,10 +86,7 @@ class DeleteReplyPageTest : WebPageTest() { addHttpRequestParameter("reply", "reply-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("abortDelete", "true") - expectedException.expect(redirectsTo("return.html")) - try { - page.processTemplate(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core, never()).deleteReply(reply) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DeleteSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DeleteSonePageTest.kt index 535aba3..9a5d1d5 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DeleteSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DeleteSonePageTest.kt @@ -1,11 +1,9 @@ package net.pterodactylus.sone.web -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.junit.Test import org.mockito.Mockito.verify -import kotlin.test.fail /** * Unit test for [DeleteSonePage]. @@ -14,6 +12,8 @@ class DeleteSonePageTest : WebPageTest() { private val page = DeleteSonePage(template, webInterface) + override fun getPage() = page + @Test fun `get request does not redirect`() { request("", GET) @@ -23,19 +23,14 @@ class DeleteSonePageTest : WebPageTest() { @Test fun `post request without delete confirmation redirects to index`() { request("", POST) - expectedException.expect(redirectsTo("index.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("index.html") } @Test fun `post request with delete confirmation deletes sone and redirects to index`() { request("", POST) addHttpRequestParameter("deleteSone", "true") - expectedException.expect(redirectsTo("index.html")) - try { - page.handleRequest(freenetRequest, templateContext) - fail() - } finally { + verifyRedirect("index.html") { verify(core).deleteSone(currentSone) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt index a794f4c..58e1eed 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt @@ -2,13 +2,11 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.notify.Notification import net.pterodactylus.util.web.Method.GET import org.junit.Test import org.mockito.Mockito.never import org.mockito.Mockito.verify -import kotlin.test.fail /** * Unit test for [DismissNotificationPage]. @@ -18,12 +16,13 @@ class DismissNotificationPageTest : WebPageTest() { private val page = DismissNotificationPage(template, webInterface) private val notification = mock() + override fun getPage() = page + @Test fun `get request with invalid notification ID redirects to return page`() { request("", GET) addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("return.html") } @Test @@ -32,11 +31,7 @@ class DismissNotificationPageTest : WebPageTest() { addNotification("notification-id", notification) addHttpRequestParameter("notification", "notification-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - fail() - } finally { + verifyRedirect("return.html") { verify(notification, never()).dismiss() } } @@ -48,11 +43,7 @@ class DismissNotificationPageTest : WebPageTest() { addNotification("notification-id", notification) addHttpRequestParameter("notification", "notification-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - fail() - } finally { + verifyRedirect("return.html") { verify(notification).dismiss() } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt index a0766ba..1b51a4f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt @@ -2,12 +2,9 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo -import net.pterodactylus.util.web.Method import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.junit.Test -import org.mockito.Mockito import org.mockito.Mockito.verify /** @@ -17,6 +14,8 @@ class DistrustPageTest : WebPageTest() { private val page = DistrustPage(template, webInterface) + override fun getPage() = page + @Test fun `get request does not redirect`() { request("", GET) @@ -27,8 +26,7 @@ class DistrustPageTest : WebPageTest() { fun `post request with invalid sone redirects to return page`() { request("", POST) addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("return.html") } @Test @@ -38,10 +36,7 @@ class DistrustPageTest : WebPageTest() { addSone("remote-sone-id", remoteSone) addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("sone", "remote-sone-id") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).distrustSone(currentSone, remoteSone) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt index 963ab1e..9e3065b 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt @@ -6,7 +6,6 @@ import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.mockBuilder import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.junit.Before @@ -25,6 +24,8 @@ class EditAlbumPageTest : WebPageTest() { private val modifier = mockBuilder() private val sone = mock() + override fun getPage() = page + @Before fun setup() { whenever(album.id).thenReturn("album-id") @@ -46,8 +47,7 @@ class EditAlbumPageTest : WebPageTest() { @Test fun `post request with invalid album redirects to invalid page`() { request("", POST) - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -56,8 +56,7 @@ class EditAlbumPageTest : WebPageTest() { whenever(sone.isLocal).thenReturn(false) addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") - expectedException.expect(redirectsTo("noPermission.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -66,10 +65,7 @@ class EditAlbumPageTest : WebPageTest() { addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") addHttpRequestParameter("moveLeft", "true") - expectedException.expect(redirectsTo("imageBrowser.html?album=parent-id")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("imageBrowser.html?album=parent-id") { verify(parentAlbum).moveAlbumUp(album) verify(core).touchConfiguration() } @@ -81,10 +77,7 @@ class EditAlbumPageTest : WebPageTest() { addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") addHttpRequestParameter("moveRight", "true") - expectedException.expect(redirectsTo("imageBrowser.html?album=parent-id")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("imageBrowser.html?album=parent-id") { verify(parentAlbum).moveAlbumDown(album) verify(core).touchConfiguration() } @@ -96,8 +89,7 @@ class EditAlbumPageTest : WebPageTest() { addAlbum("album-id", album) addHttpRequestParameter("album", "album-id") whenever(modifier.setTitle("")).thenThrow(AlbumTitleMustNotBeEmpty()) - expectedException.expect(redirectsTo("emptyAlbumTitle.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("emptyAlbumTitle.html") } @Test @@ -107,10 +99,7 @@ class EditAlbumPageTest : WebPageTest() { addHttpRequestParameter("album", "album-id") addHttpRequestParameter("title", "title") addHttpRequestParameter("description", "description") - expectedException.expect(redirectsTo("imageBrowser.html?album=album-id")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("imageBrowser.html?album=album-id") { verify(modifier).setTitle("title") verify(modifier).setDescription("description") verify(modifier).update() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/EditImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/EditImagePageTest.kt index 827eb76..04ce570 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/EditImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/EditImagePageTest.kt @@ -6,7 +6,6 @@ import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.mockBuilder import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.junit.Before @@ -26,6 +25,8 @@ class EditImagePageTest : WebPageTest() { private val sone = mock() private val album = mock() + override fun getPage() = page + @Before fun setupImage() { whenever(sone.isLocal).thenReturn(true) @@ -45,8 +46,7 @@ class EditImagePageTest : WebPageTest() { @Test fun `post request with invalid image redirects to invalid page`() { request("", POST) - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -55,8 +55,7 @@ class EditImagePageTest : WebPageTest() { whenever(sone.isLocal).thenReturn(false) addImage("image-id", image) addHttpRequestParameter("image", "image-id") - expectedException.expect(redirectsTo("noPermission.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("noPermission.html") } @Test @@ -66,10 +65,7 @@ class EditImagePageTest : WebPageTest() { addHttpRequestParameter("image", "image-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("moveLeft", "true") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(album).moveImageUp(image) verify(core).touchConfiguration() } @@ -82,10 +78,7 @@ class EditImagePageTest : WebPageTest() { addHttpRequestParameter("image", "image-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("moveRight", "true") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(album).moveImageDown(image) verify(core).touchConfiguration() } @@ -98,10 +91,7 @@ class EditImagePageTest : WebPageTest() { addHttpRequestParameter("image", "image-id") addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("title", " ") - expectedException.expect(redirectsTo("emptyImageTitle.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("emptyImageTitle.html") { verify(core, never()).touchConfiguration() } } @@ -114,10 +104,7 @@ class EditImagePageTest : WebPageTest() { addHttpRequestParameter("returnPage", "return.html") addHttpRequestParameter("title", "Title") addHttpRequestParameter("description", "Description") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(modifier).setTitle("Title") verify(modifier).setDescription("Description") verify(modifier).update() @@ -134,10 +121,7 @@ class EditImagePageTest : WebPageTest() { addHttpRequestParameter("title", "Title") addHttpRequestHeader("Host", "www.te.st") addHttpRequestParameter("description", "Get http://www.te.st/KSK@GPL.txt") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(modifier).setTitle("Title") verify(modifier).setDescription("Get KSK@GPL.txt") verify(modifier).update() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/EditProfileFieldPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/EditProfileFieldPageTest.kt index 1b896da..01d78ca 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/EditProfileFieldPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/EditProfileFieldPageTest.kt @@ -2,7 +2,6 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -22,6 +21,8 @@ class EditProfileFieldPageTest : WebPageTest() { private val profile = Profile(currentSone) private val field = profile.addField("Name") + override fun getPage() = page + @Before fun setupProfile() { whenever(currentSone.profile).thenReturn(profile) @@ -30,8 +31,7 @@ class EditProfileFieldPageTest : WebPageTest() { @Test fun `get request with invalid field redirects to invalid page`() { request("", GET) - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test @@ -47,8 +47,7 @@ class EditProfileFieldPageTest : WebPageTest() { request("", POST) addHttpRequestParameter("field", field.id) addHttpRequestParameter("cancel", "true") - expectedException.expect(redirectsTo("editProfile.html#profile-fields")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("editProfile.html#profile-fields") } @Test @@ -56,10 +55,7 @@ class EditProfileFieldPageTest : WebPageTest() { request("", POST) addHttpRequestParameter("field", field.id) addHttpRequestParameter("name", "New Name") - expectedException.expect(redirectsTo("editProfile.html#profile-fields")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("editProfile.html#profile-fields") { assertThat(field.name, equalTo("New Name")) verify(currentSone).profile = profile } @@ -70,10 +66,7 @@ class EditProfileFieldPageTest : WebPageTest() { request("", POST) addHttpRequestParameter("field", field.id) addHttpRequestParameter("name", "Name") - expectedException.expect(redirectsTo("editProfile.html#profile-fields")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("editProfile.html#profile-fields") { assertThat(field.name, equalTo("Name")) verify(currentSone, never()).profile = profile } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/EditProfilePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/EditProfilePageTest.kt index 333d985..0bdff69 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/EditProfilePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/EditProfilePageTest.kt @@ -26,6 +26,8 @@ class EditProfilePageTest : WebPageTest() { private val firstField = profile.addField("First Field") private val secondField = profile.addField("Second Field") + override fun getPage() = page + @Before fun setupProfile() { val avatar = mock() @@ -73,10 +75,7 @@ class EditProfilePageTest : WebPageTest() { request("", POST) addHttpRequestParameter("save-profile", "true") addHttpRequestParameter(fieldName, newValue.toString()) - expectedException.expect(WebTestUtils.redirectsTo("editProfile.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("editProfile.html") { verify(core).touchConfiguration() assertThat(fieldAccessor(), equalTo(expectedValue)) } @@ -153,10 +152,7 @@ class EditProfilePageTest : WebPageTest() { request("", POST) addHttpRequestParameter("add-field", "true") addHttpRequestParameter("field-name", "new-field") - expectedException.expect(WebTestUtils.redirectsTo("editProfile.html#profile-fields")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("editProfile.html#profile-fields") { assertThat(profile.getFieldByName("new-field"), notNullValue()) verify(currentSone).profile = profile verify(core).touchConfiguration() @@ -167,18 +163,14 @@ class EditProfilePageTest : WebPageTest() { fun `deleting a field redirects to delete field page`() { request("", POST) addHttpRequestParameter("delete-field-${firstField.id}", "true") - expectedException.expect(WebTestUtils.redirectsTo("deleteProfileField.html?field=${firstField.id}")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("deleteProfileField.html?field=${firstField.id}") } @Test fun `moving a field up moves the field up and redirects to the edit profile page`() { request("", POST) addHttpRequestParameter("move-up-field-${secondField.id}", "true") - expectedException.expect(WebTestUtils.redirectsTo("editProfile.html#profile-fields")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("editProfile.html#profile-fields") { assertThat(profile.fields, contains(secondField, firstField)) verify(currentSone).profile = profile } @@ -188,18 +180,14 @@ class EditProfilePageTest : WebPageTest() { fun `moving an invalid field up redirects to the invalid page`() { request("", POST) addHttpRequestParameter("move-up-field-foo", "true") - expectedException.expect(WebTestUtils.redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test fun `moving a field down moves the field down and redirects to the edit profile page`() { request("", POST) addHttpRequestParameter("move-down-field-${firstField.id}", "true") - expectedException.expect(WebTestUtils.redirectsTo("editProfile.html#profile-fields")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("editProfile.html#profile-fields") { assertThat(profile.fields, contains(secondField, firstField)) verify(currentSone).profile = profile } @@ -209,16 +197,14 @@ class EditProfilePageTest : WebPageTest() { fun `moving an invalid field down redirects to the invalid page`() { request("", POST) addHttpRequestParameter("move-down-field-foo", "true") - expectedException.expect(WebTestUtils.redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } @Test fun `editing a field redirects to the edit profile page`() { request("", POST) addHttpRequestParameter("edit-field-${firstField.id}", "true") - expectedException.expect(WebTestUtils.redirectsTo("editProfileField.html?field=${firstField.id}")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("editProfileField.html?field=${firstField.id}") } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/FollowSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/FollowSonePageTest.kt index 8eee302..1f6fc26 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/FollowSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/FollowSonePageTest.kt @@ -2,7 +2,6 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.junit.Test @@ -19,6 +18,8 @@ class FollowSonePageTest : WebPageTest() { private val page = FollowSonePage(template, webInterface) + override fun getPage() = page + @Test fun `get request does not redirect`() { request("", GET) @@ -32,10 +33,7 @@ class FollowSonePageTest : WebPageTest() { addSone("sone-id", sone) addHttpRequestParameter("sone", "sone-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).followSone(currentSone, "sone-id") verify(core).markSoneKnown(sone) } @@ -50,10 +48,7 @@ class FollowSonePageTest : WebPageTest() { addSone("sone-id2", secondSone) addHttpRequestParameter("sone", "sone-id1,sone-id2") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).followSone(currentSone, "sone-id1") verify(core).followSone(currentSone, "sone-id2") verify(core).markSoneKnown(firstSone) @@ -66,10 +61,7 @@ class FollowSonePageTest : WebPageTest() { request("", POST) addHttpRequestParameter("sone", "sone-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core, never()).followSone(ArgumentMatchers.eq(currentSone), anyString()) verify(core, never()).markSoneKnown(any()) } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/LikePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/LikePageTest.kt index aafa8fa..52f6174 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/LikePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/LikePageTest.kt @@ -13,6 +13,8 @@ class LikePageTest : WebPageTest() { private val page = LikePage(template, webInterface) + override fun getPage() = page + @Test fun `get request does not redirect`() { request("", GET) @@ -25,10 +27,7 @@ class LikePageTest : WebPageTest() { addHttpRequestParameter("type", "post") addHttpRequestParameter("post", "post-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(WebTestUtils.redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(currentSone).addLikedPostId("post-id") } } @@ -39,10 +38,7 @@ class LikePageTest : WebPageTest() { addHttpRequestParameter("type", "reply") addHttpRequestParameter("reply", "reply-id") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(WebTestUtils.redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(currentSone).addLikedReplyId("reply-id") } } @@ -52,10 +48,7 @@ class LikePageTest : WebPageTest() { request("", POST) addHttpRequestParameter("type", "foo") addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(WebTestUtils.redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verifyNoMoreInteractions(currentSone) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/LockSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/LockSonePageTest.kt index 44cd81c..7136e04 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/LockSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/LockSonePageTest.kt @@ -14,13 +14,12 @@ class LockSonePageTest : WebPageTest() { private val page = LockSonePage(template, webInterface) + override fun getPage() = page + @Test fun `locking an invalid local sone redirects to return page`() { addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(WebTestUtils.redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core, never()).lockSone(any()) } } @@ -31,10 +30,7 @@ class LockSonePageTest : WebPageTest() { val sone = mock() addLocalSone("sone-id", sone) addHttpRequestParameter("returnPage", "return.html") - expectedException.expect(WebTestUtils.redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).lockSone(sone) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/LoginPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/LoginPageTest.kt index fbfeabe..a4dea43 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/LoginPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/LoginPageTest.kt @@ -6,7 +6,6 @@ import net.pterodactylus.sone.freenet.wot.OwnIdentity import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.thenReturnMock import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -27,6 +26,8 @@ class LoginPageTest : WebPageTest() { private val sones = listOf(createSone("Sone", "Test"), createSone("Test"), createSone("Sone")) + override fun getPage() = page + private fun createSone(vararg contexts: String) = mock().apply { whenever(id).thenReturn(hashCode().toString()) val identity = mock().apply { @@ -69,10 +70,7 @@ class LoginPageTest : WebPageTest() { fun `post request with valid sone and redirects to index page`() { request("", POST) addHttpRequestParameter("sone-id", "sone2") - expectedException.expect(redirectsTo("index.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("index.html") { verify(webInterface).setCurrentSone(toadletContext, sones[1]) } } @@ -82,10 +80,7 @@ class LoginPageTest : WebPageTest() { request("", POST) addHttpRequestParameter("sone-id", "sone2") addHttpRequestParameter("target", "foo.html") - expectedException.expect(redirectsTo("foo.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("foo.html") { verify(webInterface).setCurrentSone(toadletContext, sones[1]) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/LogoutPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/LogoutPageTest.kt index 65b75e0..8120b50 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/LogoutPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/LogoutPageTest.kt @@ -1,7 +1,6 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.Test @@ -14,12 +13,11 @@ class LogoutPageTest : WebPageTest() { private val page = LogoutPage(template, webInterface) + override fun getPage() = page + @Test fun `page unsets current sone and redirects to index`() { - expectedException.expect(redirectsTo("index.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("index.html") { verify(webInterface).setCurrentSone(toadletContext, null) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/MarkAsKnownPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/MarkAsKnownPageTest.kt index e586e67..c44bbd4 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/MarkAsKnownPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/MarkAsKnownPageTest.kt @@ -4,7 +4,6 @@ import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import org.junit.Test import org.mockito.Mockito.verify @@ -15,6 +14,8 @@ class MarkAsKnownPageTest : WebPageTest() { private val page = MarkAsKnownPage(template, webInterface) + override fun getPage() = page + @Test fun `posts can be marked as known`() { addHttpRequestParameter("returnPage", "return.html") @@ -23,10 +24,7 @@ class MarkAsKnownPageTest : WebPageTest() { val posts = listOf(mock(), mock()) addPost("post1", posts[0]) addPost("post3", posts[1]) - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).markPostKnown(posts[0]) verify(core).markPostKnown(posts[1]) } @@ -40,10 +38,7 @@ class MarkAsKnownPageTest : WebPageTest() { val replies = listOf(mock(), mock()) addPostReply("reply1", replies[0]) addPostReply("reply3", replies[1]) - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).markReplyKnown(replies[0]) verify(core).markReplyKnown(replies[1]) } @@ -57,10 +52,7 @@ class MarkAsKnownPageTest : WebPageTest() { val sones = listOf(mock(), mock()) addSone("sone1", sones[0]) addSone("sone3", sones[1]) - expectedException.expect(redirectsTo("return.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("return.html") { verify(core).markSoneKnown(sones[0]) verify(core).markSoneKnown(sones[1]) } @@ -69,8 +61,7 @@ class MarkAsKnownPageTest : WebPageTest() { @Test fun `different type redirects to invalid page`() { addHttpRequestParameter("type", "foo") - expectedException.expect(redirectsTo("invalid.html")) - page.handleRequest(freenetRequest, templateContext) + verifyRedirect("invalid.html") } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/OptionsPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/OptionsPageTest.kt index c79b497..b47dc34 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/OptionsPageTest.kt @@ -6,7 +6,6 @@ import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.TRUSTED import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.web.WebTestUtils.redirectsTo import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat @@ -23,6 +22,8 @@ class OptionsPageTest : WebPageTest() { private val page = OptionsPage(template, webInterface) + override fun getPage() = page + @Before fun setupPreferences() { core.preferences.insertionDelay = 1 @@ -94,10 +95,7 @@ class OptionsPageTest : WebPageTest() { addHttpRequestParameter("show-custom-avatars", "ALWAYS") addHttpRequestParameter("load-linked-images", "ALWAYS") addHttpRequestParameter(option, setValue.toString()) - expectedException.expect(redirectsTo("options.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("options.html") { assertThat(getter(), equalTo(expectedValue)) } } @@ -149,10 +147,7 @@ class OptionsPageTest : WebPageTest() { unsetCurrentSone() request("", POST) addHttpRequestParameter(name, setValue) - expectedException.expect(redirectsTo("options.html")) - try { - page.handleRequest(freenetRequest, templateContext) - } finally { + verifyRedirect("options.html") { assertThat(getter(), equalTo(expectedValue)) } }