@@ -13,23 +13,31 @@ import com.datadog.android.rum.internal.AnonymousIdentifierReadCallback
13
13
import com.datadog.android.rum.internal.RumAnonymousIdentifierManager
14
14
import org.junit.Before
15
15
import org.junit.Test
16
- import org.mockito.Mockito.mock
16
+ import org.junit.runner.RunWith
17
+ import org.mockito.Mock
17
18
import org.mockito.Mockito.never
18
19
import org.mockito.Mockito.verify
20
+ import org.mockito.junit.MockitoJUnitRunner
19
21
import org.mockito.kotlin.any
20
22
import org.mockito.kotlin.eq
23
+ import org.mockito.kotlin.isNull
21
24
import org.mockito.kotlin.whenever
22
25
import java.util.UUID
23
26
27
+ @RunWith(MockitoJUnitRunner ::class )
24
28
class RumAnonymousIdentifierManagerTest {
25
29
30
+ @Mock
26
31
private lateinit var dataStore: DataStoreHandler
32
+
33
+ @Mock
27
34
private lateinit var core: FeatureSdkCore
28
35
36
+ private lateinit var rumAnonymousIdentifierManager: RumAnonymousIdentifierManager
37
+
29
38
@Before
30
39
fun setUp () {
31
- dataStore = mock()
32
- core = mock()
40
+ rumAnonymousIdentifierManager = RumAnonymousIdentifierManager (dataStore, core)
33
41
}
34
42
35
43
@Test
@@ -38,7 +46,7 @@ class RumAnonymousIdentifierManagerTest {
38
46
whenever(
39
47
dataStore.value(
40
48
eq(" anonymous_id_key" ),
41
- eq( null ),
49
+ isNull( ),
42
50
any<AnonymousIdentifierReadCallback >(),
43
51
any()
44
52
)
@@ -48,10 +56,10 @@ class RumAnonymousIdentifierManagerTest {
48
56
}
49
57
50
58
// When
51
- RumAnonymousIdentifierManager .manageAnonymousId(true , dataStore, core )
59
+ rumAnonymousIdentifierManager .manageAnonymousId(true )
52
60
53
61
// Then
54
- verify(dataStore).setValue(eq(" anonymous_id_key" ), any(), eq(0 ), eq( null ), any())
62
+ verify(dataStore).setValue(eq(" anonymous_id_key" ), any(), eq(0 ), isNull( ), any())
55
63
verify(core).setAnonymousId(any())
56
64
}
57
65
@@ -61,7 +69,7 @@ class RumAnonymousIdentifierManagerTest {
61
69
whenever(
62
70
dataStore.value(
63
71
eq(" anonymous_id_key" ),
64
- eq( null ),
72
+ isNull( ),
65
73
any<AnonymousIdentifierReadCallback >(),
66
74
any()
67
75
)
@@ -71,11 +79,11 @@ class RumAnonymousIdentifierManagerTest {
71
79
}
72
80
73
81
// When
74
- RumAnonymousIdentifierManager .manageAnonymousId(true , dataStore, core )
82
+ rumAnonymousIdentifierManager .manageAnonymousId(true )
75
83
76
84
// Then
77
- verify(dataStore, never()).setValue(eq(" anonymous_id_key" ), any(), eq(0 ), eq( null ), any())
78
- verify(dataStore, never()).removeValue(eq(" anonymous_id_key" ), eq( null ))
85
+ verify(dataStore, never()).setValue(eq(" anonymous_id_key" ), any(), eq(0 ), isNull( ), any())
86
+ verify(dataStore, never()).removeValue(eq(" anonymous_id_key" ), isNull( ))
79
87
verify(core).setAnonymousId(any())
80
88
}
81
89
@@ -85,10 +93,10 @@ class RumAnonymousIdentifierManagerTest {
85
93
val shouldTrack = false
86
94
87
95
// When
88
- RumAnonymousIdentifierManager .manageAnonymousId(shouldTrack, dataStore, core )
96
+ rumAnonymousIdentifierManager .manageAnonymousId(shouldTrack)
89
97
90
98
// Then
91
- verify(dataStore).removeValue(eq(" anonymous_id_key" ), eq( null ))
92
- verify(core).setAnonymousId(eq( null ))
99
+ verify(dataStore).removeValue(eq(" anonymous_id_key" ), isNull( ))
100
+ verify(core).setAnonymousId(isNull( ))
93
101
}
94
102
}
0 commit comments