import net.pterodactylus.sone.test.mock
import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.utils.asOptional
+import net.pterodactylus.sone.web.NewElements
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.notify.Notification
val preferences = Preferences(eventBus)
val updateChecker = mock<UpdateChecker>()
val elementLoader = mock<ElementLoader>()
+ val newElements = mock<NewElements>()
val toadletContext = mock<ToadletContext>()
val freenetRequest = mock<FreenetRequest>()
}
init {
- whenever(webInterface.templateContextFactory).thenReturn(TemplateContextFactory())
- whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(currentSone)
- whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone)
- whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone)
+ whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext))).thenReturn(currentSone)
whenever(webInterface.core).thenReturn(core)
whenever(webInterface.formPassword).then { formPassword }
whenever(webInterface.getNotifications(currentSone)).thenAnswer { notifications.values }
whenever(webInterface.getNotification(ArgumentMatchers.anyString())).then { notifications[it[0]].asOptional() }
- whenever(webInterface.getNewPosts(currentSone)).thenAnswer { newPosts.values }
- whenever(webInterface.getNewReplies(currentSone)).thenAnswer { newReplies.values }
whenever(webInterface.translation).thenReturn(translation)
whenever(core.preferences).thenReturn(preferences)
linkedElements[it.getArgument(0)] ?: LinkedElement(it.getArgument(0), loading = true)
}
+ whenever(newElements.newPosts).then { newPosts.values }
+ whenever(newElements.newReplies).then { newReplies.values }
+
whenever(currentSone.options).thenReturn(DefaultSoneOptions())
currentSone.mock("soneId", "Sone_Id", true, 1000, idle)
}
protected fun unsetCurrentSone() {
- whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(null)
- whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(null)
- whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(null)
+ whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext))).thenReturn(null)
}
protected fun postRequest() {