-
Notifications
You must be signed in to change notification settings - Fork 205
/
BeforeSendSessionTest.kt
40 lines (30 loc) · 1.08 KB
/
BeforeSendSessionTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.bugsnag.android
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import java.util.concurrent.CountDownLatch
class BeforeSendSessionTest {
private val client = BugsnagTestUtils.generateClient()
private val sessionTracker = client.sessionTracker
@Before
fun setUp() {
}
@Test
fun testBeforeSendCallbackInvoked() {
val latch = CountDownLatch(1)
var data: SessionTrackingPayload? = null
client.config.addBeforeSendSession { it.device["foo"] = "bar" }
client.config.addBeforeSendSession { it.device["foo2"] = 5 }
client.config.delivery = object : Delivery {
override fun deliver(payload: SessionTrackingPayload, config: Configuration) {
data = payload
latch.countDown()
}
override fun deliver(report: Report, config: Configuration) {}
}
sessionTracker.startSession(false)
latch.await()
assertEquals("bar", data!!.device["foo"])
assertEquals(5, data!!.device["foo2"])
}
}