Skip to content

Commit 37aa371

Browse files
Add missing test cases
1 parent fa44865 commit 37aa371

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/test/kotlin/com/mparticle/kits/RoktKitTests.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,42 @@ class RoktKitTests {
150150

151151
}
152152

153+
@Test
154+
fun test_addIdentityAttributes_When_userIdentities_And_attributes_contains_same_key(){
155+
val mockFilterUser = Mockito.mock(FilteredMParticleUser::class.java)
156+
val userIdentities = HashMap<IdentityType, String>()
157+
userIdentities.put(IdentityType.Email,"[email protected]")
158+
Mockito.`when`(mockFilterUser.userIdentities).thenReturn(userIdentities)
159+
val attributes: Map<String, String> = mapOf(
160+
"key1" to "value1",
161+
"key2" to "value2",
162+
"key3" to "value3",
163+
"email" to "[email protected]"
164+
)
165+
val method: Method = RoktKit::class.java.getDeclaredMethod(
166+
"addIdentityAttributes",
167+
Map::class.java,
168+
FilteredMParticleUser::class.java
169+
)
170+
method.isAccessible = true
171+
val result = method.invoke(roktKit, attributes, mockFilterUser) as Map<String, String>
172+
assertEquals(4, result.size)
173+
174+
assertTrue(result.containsKey("key1"))
175+
assertTrue(result.containsKey("key2"))
176+
assertTrue(result.containsKey("key3"))
177+
assertTrue(result.containsKey("email"))
178+
assertEquals(
179+
mapOf(
180+
"key1" to "value1",
181+
"key2" to "value2",
182+
"key3" to "value3",
183+
"email" to "[email protected]"
184+
),
185+
result
186+
)
187+
}
188+
153189
@Test
154190
fun testAddIdentityAttributes_bothNull() {
155191
val method: Method = RoktKit::class.java.getDeclaredMethod(

0 commit comments

Comments
 (0)