Refactor Author.Status into dedicated AuthorInfo class and add alias

This commit is contained in:
Torsten Grote
2018-10-29 16:49:48 -03:00
parent 969150bff0
commit 88adfabe09
37 changed files with 348 additions and 280 deletions

View File

@@ -1,6 +1,7 @@
package org.briarproject.bramble.identity
import org.briarproject.bramble.api.identity.Author
import org.briarproject.bramble.api.identity.AuthorInfo
import org.briarproject.briar.headless.json.JsonDict
fun Author.output() = JsonDict(
@@ -10,4 +11,4 @@ fun Author.output() = JsonDict(
"publicKey" to publicKey
)
fun Author.Status.output() = name.toLowerCase()
fun AuthorInfo.Status.output() = name.toLowerCase()

View File

@@ -8,7 +8,7 @@ import org.briarproject.briar.headless.json.JsonDict
internal fun BlogPostHeader.output(text: String) = JsonDict(
"text" to text,
"author" to author.output(),
"authorStatus" to authorStatus.output(),
"authorStatus" to authorInfo.status.output(),
"type" to type.output(),
"id" to id.bytes,
"parentId" to parentId?.bytes,

View File

@@ -6,7 +6,8 @@ import io.mockk.Runs
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import org.briarproject.bramble.api.identity.Author.Status.OURSELVES
import org.briarproject.bramble.api.identity.AuthorInfo
import org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES
import org.briarproject.bramble.api.sync.MessageId
import org.briarproject.bramble.identity.output
import org.briarproject.bramble.util.StringUtils.getRandomString
@@ -30,8 +31,16 @@ internal class BlogControllerTest : ControllerTest() {
private val rssFeed = false
private val read = true
private val header = BlogPostHeader(
POST, group.id, message.id, parentId, message.timestamp, timestamp, author, OURSELVES,
rssFeed, read
POST,
group.id,
message.id,
parentId,
message.timestamp,
timestamp,
author,
AuthorInfo(OURSELVES),
rssFeed,
read
)
@Test