package net.pterodactylus.sone.fcp
-import com.google.common.base.Optional
import com.google.common.base.Optional.absent
import freenet.support.SimpleFieldSet
import net.pterodactylus.sone.core.Core
@Before
fun setupCore() {
- whenever(core.getSone(anyString())).thenReturn(absent())
- whenever(core.getPost(anyString())).thenReturn(absent())
- whenever(core.getPostReply(anyString())).thenReturn(absent())
+ whenever(core.getSone(anyString())).thenReturn(null)
+ whenever(core.getPost(anyString())).thenReturn(null)
+ whenever(core.getPostReply(anyString())).thenReturn(null)
}
protected fun createSone(id: String, name: String, firstName: String, lastName: String, time: Long) = mock<Sone>().apply {
fun requestWithValidRemoteSoneParameterResultsInFcpException() {
parameters += "Sone" to "RemoteSoneId"
- whenever(core.getSone("RemoteSoneId")).thenReturn(Optional.of(remoteSone))
+ whenever(core.getSone("RemoteSoneId")).thenReturn(remoteSone)
executeCommandAndExpectFcpException()
}
("Field." + this["${prefix}Field.$it.Name"]) to this["${prefix}Field.$it.Value"]
}
- private fun SimpleFieldSet.parseFromSimpleFieldSet(prefix: String, vararg fields: String) = listOf(*fields)
- .map { it to (get(prefix + it) as String?) }
- .toMap()
+ private fun SimpleFieldSet.parseFromSimpleFieldSet(prefix: String, vararg fields: String): Map<String, String?> = fields
+ .associate { it to get(prefix + it) }
protected fun matchesPost(post: Post) = OneByOneMatcher<Map<String, String?>>().apply {
expect("ID", post.id) { it["ID"] }