@@ -265,7 +265,69 @@ class RoktKitTests {
265265 assertTrue(result.containsKey(" key2" ))
266266 assertTrue(result.containsKey(" key3" ))
267267 assertTrue(result.containsKey(" email" ))
268- assertTrue(result.containsKey(" emailsha256" ))
268+ assertTrue(result.containsKey(" other" ))
269+ }
270+
271+ @Test
272+ fun test_addIdentityAttributes_When_userIdentities_Other_map_To_Identity () {
273+ val mockFilterUser = mock(FilteredMParticleUser ::class .java)
274+ val userIdentities = HashMap <IdentityType , String >()
275+ userIdentities.put(IdentityType .Email , " TestEmail@gamil.com" )
276+ userIdentities.put(IdentityType .Other , " hashedEmail@123.com" )
277+ Mockito .`when `(mockFilterUser.userIdentities).thenReturn(userIdentities)
278+ val attributes: Map <String , String > = mapOf (
279+ " key1" to " value1" ,
280+ " key2" to " value2" ,
281+ " key3" to " value3" ,
282+ )
283+ val hashedField = RoktKit ::class .java.getDeclaredField(" hashedEmailUserIdentityType" )
284+ hashedField.isAccessible = true
285+ hashedField.set(roktKit, " Other" )
286+ val method: Method = RoktKit ::class .java.getDeclaredMethod(
287+ " addIdentityAttributes" ,
288+ Map ::class .java,
289+ FilteredMParticleUser ::class .java,
290+ )
291+ method.isAccessible = true
292+ val result = method.invoke(roktKit, attributes, mockFilterUser) as Map <String , String >
293+ assertEquals(5 , result.size)
294+
295+ assertTrue(result.containsKey(" key1" ))
296+ assertTrue(result.containsKey(" key2" ))
297+ assertTrue(result.containsKey(" key3" ))
298+ assertTrue(result.containsKey(" email" ))
299+ assertTrue(result.containsKey(" other" ))
300+ }
301+
302+ @Test
303+ fun test_addIdentityAttributes_When_userIdentities_Unknown_map_To_Identity () {
304+ val mockFilterUser = mock(FilteredMParticleUser ::class .java)
305+ val userIdentities = HashMap <IdentityType , String >()
306+ userIdentities.put(IdentityType .Email , " TestEmail@gamil.com" )
307+ userIdentities.put(IdentityType .Other , " hashedEmail@123.com" )
308+ Mockito .`when `(mockFilterUser.userIdentities).thenReturn(userIdentities)
309+ val attributes: Map <String , String > = mapOf (
310+ " key1" to " value1" ,
311+ " key2" to " value2" ,
312+ " key3" to " value3" ,
313+ )
314+ val hashedField = RoktKit ::class .java.getDeclaredField(" hashedEmailUserIdentityType" )
315+ hashedField.isAccessible = true
316+ hashedField.set(roktKit, " Unknown" )
317+ val method: Method = RoktKit ::class .java.getDeclaredMethod(
318+ " addIdentityAttributes" ,
319+ Map ::class .java,
320+ FilteredMParticleUser ::class .java,
321+ )
322+ method.isAccessible = true
323+ val result = method.invoke(roktKit, attributes, mockFilterUser) as Map <String , String >
324+ assertEquals(5 , result.size)
325+
326+ assertTrue(result.containsKey(" key1" ))
327+ assertTrue(result.containsKey(" key2" ))
328+ assertTrue(result.containsKey(" key3" ))
329+ assertTrue(result.containsKey(" email" ))
330+ assertTrue(result.containsKey(" other" ))
269331 }
270332
271333 @Test
@@ -672,7 +734,7 @@ class RoktKitTests {
672734
673735 override fun setIntegrationAttributes (kitId : Int , integrationAttributes : Map <String , String >) {}
674736
675- override fun getIntegrationAttributes (kitId : Int ): Map <String , String >? = null
737+ override fun getIntegrationAttributes (i : Int ): Map <String , String >? = null
676738
677739 override fun getCurrentActivity (): WeakReference <Activity > = WeakReference (activity)
678740
0 commit comments