/**
* Unit test for [LoginPage].
*/
-class LoginPageTest : WebPageTest() {
-
- private val page = LoginPage(template, webInterface)
+class LoginPageTest: WebPageTest2(::LoginPage) {
private val sones = listOf(createSone("Sone", "Test"), createSone("Test"), createSone("Sone"))
- override fun getPage() = page
-
private fun createSone(vararg contexts: String) = mock<Sone>().apply {
whenever(id).thenReturn(hashCode().toString())
val identity = mock<OwnIdentity>().apply {
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.freenet.wot.OwnIdentity
import net.pterodactylus.sone.test.deepMock
import net.pterodactylus.sone.test.get
import net.pterodactylus.sone.test.mock
private val requestHeaders = mutableMapOf<String, String>()
private val getRequestParameters = mutableMapOf<String, MutableList<String>>()
private val postRequestParameters = mutableMapOf<String, ByteArray>()
+ private val ownIdentities = mutableSetOf<OwnIdentity>()
private val allSones = mutableMapOf<String, Sone>()
private val localSones = mutableMapOf<String, Sone>()
private val allPosts = mutableMapOf<String, Post>()
@Before
fun setupCore() {
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.localSones).then { localSones.values }
whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(null)
}
+ fun addOwnIdentity(ownIdentity: OwnIdentity) {
+ ownIdentities += ownIdentity
+ }
+
fun addSone(id: String, sone: Sone) {
allSones[id] = sone
}