-
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.
test: added unit tests for string conversion to map and list
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
core/src/test/java/com/rudderstack/android/sdk/core/UtilsTest.java
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,26 @@ | ||
package com.rudderstack.android.sdk.core; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import com.rudderstack.android.sdk.core.util.Utils; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class UtilsTest { | ||
@Test | ||
public void testStringConversiontToMap() { | ||
String rudderTraits = "{\"dirty\":{\"general\":45.0,\"minValue\":4.9E-324,\"maxValue\":1.7976931348623157E308,\"double\":45.0,\"positiveInfinity\":\"Infinity\",\"nan\":\"NaN\",\"float\":45.0,\"list\":[\"Infinity\",\"-Infinity\",1.7976931348623157E308,4.9E-324,\"NaN\",45.0,45.0],\"map\":{\"general\":45.0,\"minValue\":4.9E-324,\"maxValue\":1.7976931348623157E308,\"double\":45.0,\"positiveInfinity\":\"Infinity\",\"nan\":\"NaN\",\"negativeInfinity\":\"-Infinity\"},\"long\":45.0,\"int\":45.0,\"negativeInfinity\":\"-Infinity\"},\"anonymousId\":\"c5ee2cf1-97a3-4744-80fc-faabce7a7e51\",\"name\":\"Mr. User1\",\"id\":\"new user 2\",\"userId\":\"new user 2\",\"email\":\"[email protected]\"}"; | ||
Map<String,Object> map = Utils.convertToMap(rudderTraits); | ||
assertThat("Map should not be empty", map.size() > 0); | ||
} | ||
|
||
@Test | ||
public void testStringConversionToArray() { | ||
String externalIds = "[{\"id\":\"idValue\",\"type\":\"idTYpe\"}]"; | ||
List<Map<String, Object>> list = Utils.convertToList(externalIds); | ||
assertThat("List should not be empty", list.size() > 0); | ||
} | ||
} |