mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
@@ -14,6 +14,7 @@ import org.briarproject.bramble.api.sync.Message
|
||||
import org.briarproject.bramble.api.system.Clock
|
||||
import org.briarproject.bramble.test.TestUtils.*
|
||||
import org.briarproject.bramble.util.StringUtils.getRandomString
|
||||
import org.briarproject.briar.api.conversation.ConversationManager
|
||||
import org.briarproject.briar.headless.event.WebSocketController
|
||||
import org.skyscreamer.jsonassert.JSONAssert.assertEquals
|
||||
import org.skyscreamer.jsonassert.JSONCompareMode.STRICT
|
||||
@@ -23,6 +24,7 @@ import javax.servlet.http.HttpServletResponse
|
||||
abstract class ControllerTest {
|
||||
|
||||
protected val contactManager = mockk<ContactManager>()
|
||||
protected val conversationManager = mockk<ConversationManager>()
|
||||
protected val identityManager = mockk<IdentityManager>()
|
||||
protected val clock = mockk<Clock>()
|
||||
protected val ctx = mockk<Context>()
|
||||
|
||||
@@ -35,7 +35,7 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
private val pendingContact = getPendingContact()
|
||||
|
||||
private val controller =
|
||||
ContactControllerImpl(contactManager, objectMapper, webSocketController)
|
||||
ContactControllerImpl(contactManager, conversationManager, objectMapper, webSocketController)
|
||||
|
||||
@Test
|
||||
fun testEmptyContactList() {
|
||||
@@ -47,7 +47,8 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
@Test
|
||||
fun testList() {
|
||||
every { contactManager.contacts } returns listOf(contact)
|
||||
every { ctx.json(listOf(contact.output())) } returns ctx
|
||||
every { conversationManager.getGroupCount(contact.id).latestMsgTime } returns timestamp
|
||||
every { ctx.json(listOf(contact.output(conversationManager))) } returns ctx
|
||||
controller.list(ctx)
|
||||
}
|
||||
|
||||
@@ -264,6 +265,7 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
|
||||
@Test
|
||||
fun testOutputContact() {
|
||||
every { conversationManager.getGroupCount(contact.id).latestMsgTime } returns timestamp
|
||||
assertNotNull(contact.handshakePublicKey)
|
||||
val json = """
|
||||
{
|
||||
@@ -271,10 +273,11 @@ internal class ContactControllerTest : ControllerTest() {
|
||||
"author": ${toJson(author.output())},
|
||||
"alias" : "${contact.alias}",
|
||||
"handshakePublicKey": ${toJson(contact.handshakePublicKey!!.encoded)},
|
||||
"verified": ${contact.isVerified}
|
||||
"verified": ${contact.isVerified},
|
||||
"lastChatActivity": ${timestamp}
|
||||
}
|
||||
"""
|
||||
assertJsonEquals(json, contact.output())
|
||||
assertJsonEquals(json, contact.output(conversationManager))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.junit.jupiter.api.Test
|
||||
internal class MessagingControllerImplTest : ControllerTest() {
|
||||
|
||||
private val messagingManager = mockk<MessagingManager>()
|
||||
private val conversationManager = mockk<ConversationManager>()
|
||||
private val privateMessageFactory = mockk<PrivateMessageFactory>()
|
||||
private val dbExecutor = ImmediateExecutor()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user