-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent setting duplicate externalId types (#446)
* chore: fix indentation of MessageUtilsTest * fix: merging of externalIds Currently, even if the externalId.type is same they are not merged. Ideally they should be merged in such cases. * test: add test cases related to the merging of the externalId option * test: refactor test method names
- Loading branch information
1 parent
df81123
commit 213a584
Showing
5 changed files
with
147 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
core/src/test/java/com/rudderstack/core/RudderOptionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.rudderstack.core | ||
|
||
import junit.framework.TestCase.assertEquals | ||
import org.junit.Test | ||
|
||
class RudderOptionTest { | ||
@Test | ||
fun `given all the externalIds are of different type, when externalIds are passed, they should be added to the list`() { | ||
val rudderOption = RudderOption().apply { | ||
putExternalId("brazeExternalID", "12345") | ||
putExternalId("amplitudeExternalID", "67890") | ||
} | ||
|
||
val expectedExternalIds = listOf( | ||
mapOf("type" to "brazeExternalID", "id" to "12345"), | ||
mapOf("type" to "amplitudeExternalID", "id" to "67890"), | ||
) | ||
|
||
assertEquals(expectedExternalIds, rudderOption.externalIds) | ||
} | ||
|
||
@Test | ||
fun `given few externalIds have same type but different Ids, when externalIds are passed, they should be merged in the list`() { | ||
val rudderOption = RudderOption().apply { | ||
putExternalId("brazeExternalID", "12345") | ||
putExternalId("brazeExternalID", "67890") | ||
putExternalId("amplitudeExternalID", "67890") | ||
} | ||
|
||
val expectedExternalIds = listOf( | ||
mapOf("type" to "brazeExternalID", "id" to "67890"), | ||
mapOf("type" to "amplitudeExternalID", "id" to "67890"), | ||
) | ||
|
||
assertEquals(expectedExternalIds, rudderOption.externalIds) | ||
} | ||
|
||
@Test | ||
fun `given few externalIds have same type and Ids, when externalIds are passed, they should be merged in the list`() { | ||
val rudderOption = RudderOption().apply { | ||
putExternalId("brazeExternalID", "12345") | ||
putExternalId("brazeExternalID", "12345") | ||
} | ||
|
||
val expectedExternalIds = listOf( | ||
mapOf("type" to "brazeExternalID", "id" to "12345"), | ||
) | ||
|
||
assertEquals(expectedExternalIds, rudderOption.externalIds) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters