Allow adding replies without specific ID
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / ajax / JsonPageTest.kt
index 4dddbe5..60b2627 100644 (file)
@@ -52,7 +52,7 @@ abstract class JsonPageTest(
        protected val preferences = Preferences(eventBus)
        protected val elementLoader = mock<ElementLoader>()
        protected open val page: JsonPage by lazy { pageSupplier(webInterface) }
-       protected val json by lazy { page.createJsonObject(freenetRequest)!! }
+       protected val json by lazy { page.createJsonObject(freenetRequest) }
 
        protected val toadletContext = mock<ToadletContext>()
        protected val freenetRequest = mock<FreenetRequest>()
@@ -178,8 +178,8 @@ abstract class JsonPageTest(
                localSones += id to sone
        }
 
-       protected fun addPost(id: String, post: Post) {
-               posts[id] = post
+       protected fun addPost(post: Post, id: String? = null) {
+               posts[id ?: post.id] = post
        }
 
        protected fun addNewPost(id: String, soneId: String, time: Long, recipientId: String? = null) =
@@ -191,8 +191,8 @@ abstract class JsonPageTest(
                                whenever(this.recipientId).thenReturn(recipientId.asOptional())
                        }.also { newPosts[id] = it }
 
-       protected fun addReply(id: String, reply: PostReply) {
-               replies[id] = reply
+       protected fun addReply(reply: PostReply, id: String? = null) {
+               replies[id ?: reply.id] = reply
        }
 
        protected fun addNewReply(id: String, soneId: String, postId: String, postSoneId: String) {