import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.data.TemporaryImage
import net.pterodactylus.sone.freenet.wot.OwnIdentity
import net.pterodactylus.sone.test.deepMock
import net.pterodactylus.sone.test.get
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException
+import net.pterodactylus.util.notify.Notification
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import net.pterodactylus.util.web.Method
private val perPostReplies = mutableMapOf<String, PostReply>()
private val allAlbums = mutableMapOf<String, Album>()
private val allImages = mutableMapOf<String, Image>()
+ private val notifications = mutableMapOf<String, Notification>()
private val translations = mutableMapOf<String, String>()
init {
whenever(core.getAlbum(anyString())).then { allAlbums[it[0]] }
whenever(core.getImage(anyString())).then { allImages[it[0]]}
whenever(core.getImage(anyString(), anyBoolean())).then { allImages[it[0]]}
+ whenever(core.getTemporaryImage(anyString())).thenReturn(null)
}
private fun setupWebInterface() {
whenever(webInterface.getCurrentSoneCreatingSession(eq(toadletContext))).thenReturn(currentSone)
whenever(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(currentSone)
whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(currentSone)
- whenever(webInterface.getNotifications(currentSone)).thenReturn(emptyList())
+ whenever(webInterface.getNotifications(currentSone)).then { notifications.values }
+ whenever(webInterface.getNotification(anyString())).then { notifications[it[0]].asOptional() }
}
private fun setupHttpRequest() {
translations[key] = value
}
+ fun addNotification(id: String, notification: Notification) {
+ notifications[id] = notification
+ }
+
+ fun addTemporaryImage(id: String, temporaryImage: TemporaryImage) {
+ whenever(core.getTemporaryImage(id)).thenReturn(temporaryImage)
+ }
+
fun verifyNoRedirect(assertions: () -> Unit) {
var caughtException: Exception? = null
try {