1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.test.*
5 import net.pterodactylus.sone.web.*
6 import org.hamcrest.MatcherAssert.*
7 import org.hamcrest.Matchers.*
9 import org.mockito.Mockito.*
12 * Unit test for [UnlockSoneAjaxPage].
14 class UnlockSoneAjaxPageTest : JsonPageTest("unlockSone.ajax", requiresLogin = false, pageSupplier = ::UnlockSoneAjaxPage) {
17 fun `request without sone results in invalid-sone-id`() {
18 assertThatJsonFailed("invalid-sone-id")
22 fun `request with invalid sone results in invalid-sone-id`() {
23 addRequestParameter("sone", "invalid")
24 assertThatJsonFailed("invalid-sone-id")
28 fun `request with valid sone results in locked sone`() {
29 val sone = mock<Sone>()
30 addLocalSone(sone, "sone-id")
31 addRequestParameter("sone", "sone-id")
32 assertThatJsonIsSuccessful()
33 verify(core).unlockSone(sone)
37 fun `page can be created by dependency injection`() {
38 assertThat(baseInjector.getInstance<UnlockSoneAjaxPage>(), notNullValue())