X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonPageTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonPageTest.kt;h=f3558fa94fe229eedef53000be34205916bbf7f5;hp=cdb68a369d6bda80550c23a74edc5b66698af6e5;hb=e5224bcc64cbbe5b0396984554d76dc3a5960e80;hpb=e36e66709507f77ca27641d882066f730d06c651 diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt index cdb68a3..f3558fa 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt @@ -64,7 +64,7 @@ abstract class JsonPageTest( private val replies = mutableMapOf() private val newReplies = mutableMapOf() private val linkedElements = mutableMapOf() - private val notifications = mutableListOf() + private val notifications = mutableMapOf() @Before fun setupWebInterface() { @@ -72,7 +72,8 @@ abstract class JsonPageTest( whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone) whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone) whenever(webInterface.core).thenReturn(core) - whenever(webInterface.getNotifications(currentSone)).thenAnswer { notifications } + whenever(webInterface.getNotifications(currentSone)).thenAnswer { notifications.values } + whenever(webInterface.getNotification(anyString())).then { notifications[it[0]].asOptional() } whenever(webInterface.getNewPosts(currentSone)).thenAnswer { newPosts.values } whenever(webInterface.getNewReplies(currentSone)).thenAnswer { newReplies.values } } @@ -153,8 +154,8 @@ abstract class JsonPageTest( requestParts += key to value } - protected fun addNotification(vararg notifications: Notification) { - this.notifications += notifications + protected fun addNotification(notification: Notification, notificationId: String? = null) { + notifications[notificationId ?: notification.id] = notification } protected fun addSone(sone: Sone) {