- protected val webInterface = mock<WebInterface>()
- protected val core = mock<Core>()
- protected val elementLoader = mock<ElementLoader>()
- protected open lateinit var page: JsonPage
- protected val json by lazy { page.createJsonObject(freenetRequest)!! }
-
- protected val toadletContext = mock<ToadletContext>()
- protected val freenetRequest = mock<FreenetRequest>()
- protected val httpRequest = mock<HTTPRequest>()
- protected val currentSone = deepMock<Sone>()
-
- private val requestParameters = mutableMapOf<String, String>()
- private val localSones = mutableMapOf<String, Sone>()
- private val remoteSones = mutableMapOf<String, Sone>()
- private val newPosts = mutableMapOf<String, Post>()
- private val newReplies = mutableMapOf<String, PostReply>()
- private val linkedElements = mutableMapOf<String, LinkedElement>()
- private val notifications = mutableListOf<Notification>()
-
- @Before
- fun setupWebInterface() {
- 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.getNewPosts(currentSone)).thenAnswer { newPosts.values }
- whenever(webInterface.getNewReplies(currentSone)).thenAnswer { newReplies.values }
- }
-
- @Before
- fun setupCore() {
- whenever(core.getSone(anyString())).thenAnswer { (localSones + remoteSones)[it.getArgument(0)].asOptional() }
- }
-
- @Before
- fun setupElementLoader() {
- whenever(elementLoader.loadElement(anyString())).thenAnswer {
- linkedElements[it.getArgument(0)] ?: LinkedElement(it.getArgument(0), loading = true)
- }
- }
-
- @Before
- fun setupCurrentSone() {
- currentSone.mock("soneId", "Sone_Id", true, 1000, idle)