projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
♻️ Use SoneRequest instead of FreenetRequest
[Sone.git]
/
src
/
test
/
kotlin
/
net
/
pterodactylus
/
sone
/
web
/
pages
/
WebPageTest.kt
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt
index
a1fc2de
..
e3d3410
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt
@@
-20,7
+20,7
@@
import net.pterodactylus.sone.test.whenever
import net.pterodactylus.sone.utils.asList
import net.pterodactylus.sone.utils.asOptional
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.utils.asList
import net.pterodactylus.sone.utils.asOptional
import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.
FreenetRequest
+import net.pterodactylus.sone.web.page.
*
import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException
import net.pterodactylus.util.notify.Notification
import net.pterodactylus.util.template.Template
import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException
import net.pterodactylus.util.notify.Notification
import net.pterodactylus.util.template.Template
@@
-42,7
+42,7
@@
import kotlin.text.Charsets.UTF_8
/**
* Base class for web page tests.
*/
/**
* Base class for web page tests.
*/
-open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePage = { _, _ -> mock
<SoneTemplatePage>
() }) {
+open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePage = { _, _ -> mock() }) {
val currentSone = mock<Sone>()
val template = mock<Template>()
val currentSone = mock<Sone>()
val template = mock<Template>()
@@
-55,6
+55,11
@@
open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag
val page by lazy { pageSupplier(template, webInterface) }
val httpRequest = mock<HTTPRequest>()
val freenetRequest = mock<FreenetRequest>()
val page by lazy { pageSupplier(template, webInterface) }
val httpRequest = mock<HTTPRequest>()
val freenetRequest = mock<FreenetRequest>()
+ init {
+ whenever(freenetRequest.l10n).thenReturn(l10n)
+ whenever(freenetRequest.uri).thenReturn(mock())
+ }
+ val soneRequest by lazy { freenetRequest.toSoneRequest(core, webInterface) }
val templateContext = TemplateContext()
val toadletContext = deepMock<ToadletContext>()
val responseContent = ByteArrayOutputStream()
val templateContext = TemplateContext()
val toadletContext = deepMock<ToadletContext>()
val responseContent = ByteArrayOutputStream()
@@
-89,11
+94,11
@@
open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag
whenever(core.preferences).thenReturn(preferences)
whenever(core.identityManager.allOwnIdentities).then { ownIdentities }
whenever(core.sones).then { allSones.values }
whenever(core.preferences).thenReturn(preferences)
whenever(core.identityManager.allOwnIdentities).then { ownIdentities }
whenever(core.sones).then { allSones.values }
- whenever(core.getSone(anyString())).then { allSones[it[0]]
.asOptional()
}
+ whenever(core.getSone(anyString())).then { allSones[it[0]] }
whenever(core.localSones).then { localSones.values }
whenever(core.getLocalSone(anyString())).then { localSones[it[0]] }
whenever(core.localSones).then { localSones.values }
whenever(core.getLocalSone(anyString())).then { localSones[it[0]] }
- whenever(core.getPost(anyString())).then { allPosts[it[0]]
.asOptional()
}
- whenever(core.getPostReply(anyString())).then { allPostReplies[it[0]]
.asOptional()
}
+ whenever(core.getPost(anyString())).then { allPosts[it[0]] }
+ whenever(core.getPostReply(anyString())).then { allPostReplies[it[0]] }
whenever(core.getReplies(anyString())).then { perPostReplies[it[0]].asList() }
whenever(core.getAlbum(anyString())).then { allAlbums[it[0]] }
whenever(core.getImage(anyString())).then { allImages[it[0]]}
whenever(core.getReplies(anyString())).then { perPostReplies[it[0]].asList() }
whenever(core.getAlbum(anyString())).then { allAlbums[it[0]] }
whenever(core.getImage(anyString())).then { allImages[it[0]]}
@@
-164,7
+169,7
@@
open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag
}
fun addHttpRequestParameter(name: String, value: String) {
}
fun addHttpRequestParameter(name: String, value: String) {
- getRequestParameters[name] = getRequestParameters.getOrElse(name) { mutableListOf
<String>
() }.apply { add(value) }
+ getRequestParameters[name] = getRequestParameters.getOrElse(name) { mutableListOf() }.apply { add(value) }
}
fun addHttpRequestPart(name: String, value: String) {
}
fun addHttpRequestPart(name: String, value: String) {