X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetNotificationsAjaxPageTest.kt;h=f2206e30debef8dfcdcd8f0ce56ac00d0b3698f4;hp=9084260b61bb326399b3c4fca06afea2032bc9fd;hb=d58ef344b43543fdcfca13c07df87e194f004376;hpb=959d2b0a4c4636c73d531d1097f062bf5f8e3edf 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 9084260..f2206e3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt @@ -44,15 +44,15 @@ class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requi fun `notification hash is calculated correctly`() { testNotifications.forEach { addNotification(it) } assertThat(json.isSuccess, equalTo(true)) - assertThat(json["notificationHash"].asInt(), equalTo(listOf(1, 0, 2).map(testNotifications::get).hashCode())) + assertThat(json["notificationHash"]?.asInt(), equalTo(listOf(1, 0, 2).map(testNotifications::get).hashCode())) } @Test fun `options are included correctly`() { assertThat(json.isSuccess, equalTo(true)) - assertThat(json["options"]["ShowNotification/NewSones"].asBoolean(), equalTo(true)) - assertThat(json["options"]["ShowNotification/NewPosts"].asBoolean(), equalTo(true)) - assertThat(json["options"]["ShowNotification/NewReplies"].asBoolean(), equalTo(true)) + assertThat(json["options"]!!["ShowNotification/NewSones"].asBoolean(), equalTo(true)) + assertThat(json["options"]!!["ShowNotification/NewPosts"].asBoolean(), equalTo(true)) + assertThat(json["options"]!!["ShowNotification/NewReplies"].asBoolean(), equalTo(true)) } @Test @@ -61,23 +61,23 @@ class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requi currentSone.options.isShowNewPostNotifications = false currentSone.options.isShowNewReplyNotifications = false assertThat(json.isSuccess, equalTo(true)) - assertThat(json["options"]["ShowNotification/NewSones"].asBoolean(), equalTo(false)) - assertThat(json["options"]["ShowNotification/NewPosts"].asBoolean(), equalTo(false)) - assertThat(json["options"]["ShowNotification/NewReplies"].asBoolean(), equalTo(false)) + assertThat(json["options"]!!["ShowNotification/NewSones"].asBoolean(), equalTo(false)) + assertThat(json["options"]!!["ShowNotification/NewPosts"].asBoolean(), equalTo(false)) + assertThat(json["options"]!!["ShowNotification/NewReplies"].asBoolean(), equalTo(false)) } @Test fun `options are not included if user is not logged in`() { unsetCurrentSone() assertThat(json.isSuccess, equalTo(true)) - assertThat(json["options"].toList(), empty()) + assertThat(json["options"]?.toList(), empty()) } @Test fun `notifications are rendered correctly`() { testNotifications.forEach { addNotification(it) } assertThat(json.isSuccess, equalTo(true)) - assertThat(json["notifications"].toList().map { node -> listOf("id", "text", "createdTime", "lastUpdatedTime", "dismissable").map { it to node.get(it).asText() }.toMap() }, containsInAnyOrder( + assertThat(json["notifications"]!!.toList().map { node -> listOf("id", "text", "createdTime", "lastUpdatedTime", "dismissable").map { it to node.get(it).asText() }.toMap() }, containsInAnyOrder( mapOf("id" to "n1", "createdTime" to "2000", "lastUpdatedTime" to "5000", "dismissable" to "true", "text" to "t1"), mapOf("id" to "n2", "createdTime" to "1000", "lastUpdatedTime" to "6000", "dismissable" to "false", "text" to "t2"), mapOf("id" to "n3", "createdTime" to "3000", "lastUpdatedTime" to "7000", "dismissable" to "true", "text" to "t3") @@ -100,7 +100,7 @@ class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requi testNotifications.forEach { addNotification(it) } addNotification(templateNotification) assertThat(json.isSuccess, equalTo(true)) - assertThat(json["notifications"].last()["text"].asText(), equalTo("t4")) + assertThat(json["notifications"]!!.last()["text"].asText(), equalTo("t4")) val templateContext = argumentCaptor() verify(templateNotification).render(templateContext.capture(), any()) assertThat(templateContext.value["core"], equalTo(core))