@@ -996,8 +996,6 @@ class AsyncAnalyticsTests {
996
996
997
997
@BeforeEach
998
998
fun setup () {
999
- clearPersistentStorage()
1000
-
1001
999
httpSemaphore = Semaphore (0 )
1002
1000
assertSemaphore = Semaphore (0 )
1003
1001
@@ -1028,14 +1026,14 @@ class AsyncAnalyticsTests {
1028
1026
input
1029
1027
}
1030
1028
analytics = Analytics (Configuration (writeKey = " 123" , application = " Test" ))
1029
+ analytics.add(afterPlugin)
1031
1030
}
1032
1031
1033
1032
@Test
1034
1033
fun `startup queue should replay with track enrichment closure` () {
1035
1034
val expectedEvent = " foo"
1036
1035
val expectedAnonymousId = " bar"
1037
1036
1038
- analytics.add(afterPlugin)
1039
1037
analytics.track(expectedEvent) {
1040
1038
it?.anonymousId = expectedAnonymousId
1041
1039
it
@@ -1057,39 +1055,38 @@ class AsyncAnalyticsTests {
1057
1055
}
1058
1056
}
1059
1057
1060
- // @Test
1061
- // fun `startup queue should replay with identify enrichment closure`() {
1062
- // val expected = buildJsonObject {
1063
- // put("foo", "baz")
1064
- // }
1065
- // val expectedUserId = "newUserId"
1066
- //
1067
- // analytics.add(afterPlugin)
1068
- // analytics.identify(expectedUserId) {
1069
- // if (it is IdentifyEvent) {
1070
- // it.traits = updateJsonObject(it.traits) {
1071
- // it["foo"] = "baz"
1072
- // }
1073
- // }
1074
- // it
1075
- // }
1076
- //
1077
- // // now we have tracked event, i.e. event added to startup queue
1078
- // // release the semaphore put on http client, so we startup queue will replay the events
1079
- // httpSemaphore.release()
1080
- // // now we need to wait for events being fully replayed before making assertions
1081
- // assertSemaphore.acquire()
1082
- //
1083
- // val actualUserId = analytics.userId()
1084
- //
1085
- // assertTrue(actual.isCaptured)
1086
- // actual.captured.let {
1087
- // assertTrue(it is IdentifyEvent)
1088
- // val e = it as IdentifyEvent
1089
- // assertEquals(expected, e.traits)
1090
- // assertEquals(expectedUserId, actualUserId)
1091
- // }
1092
- // }
1058
+ @Test
1059
+ fun `startup queue should replay with identify enrichment closure` () {
1060
+ val expected = buildJsonObject {
1061
+ put(" foo" , " baz" )
1062
+ }
1063
+ val expectedUserId = " newUserId"
1064
+
1065
+ analytics.identify(expectedUserId) {
1066
+ if (it is IdentifyEvent ) {
1067
+ it.traits = updateJsonObject(it.traits) {
1068
+ it[" foo" ] = " baz"
1069
+ }
1070
+ }
1071
+ it
1072
+ }
1073
+
1074
+ // now we have tracked event, i.e. event added to startup queue
1075
+ // release the semaphore put on http client, so we startup queue will replay the events
1076
+ httpSemaphore.release()
1077
+ // now we need to wait for events being fully replayed before making assertions
1078
+ assertSemaphore.acquire()
1079
+
1080
+ val actualUserId = analytics.userId()
1081
+
1082
+ assertTrue(actual.isCaptured)
1083
+ actual.captured.let {
1084
+ assertTrue(it is IdentifyEvent )
1085
+ val e = it as IdentifyEvent
1086
+ assertEquals(expected, e.traits)
1087
+ assertEquals(expectedUserId, actualUserId)
1088
+ }
1089
+ }
1093
1090
1094
1091
@Test
1095
1092
fun `startup queue should replay with group enrichment closure` () {
@@ -1098,7 +1095,6 @@ class AsyncAnalyticsTests {
1098
1095
}
1099
1096
val expectedGroupId = " foo"
1100
1097
1101
- analytics.add(afterPlugin)
1102
1098
analytics.group(expectedGroupId) {
1103
1099
if (it is GroupEvent ) {
1104
1100
it.traits = updateJsonObject(it.traits) {
@@ -1127,7 +1123,6 @@ class AsyncAnalyticsTests {
1127
1123
fun `startup queue should replay with alias enrichment closure` () {
1128
1124
val expected = " bar"
1129
1125
1130
- analytics.add(afterPlugin)
1131
1126
analytics.alias(expected) {
1132
1127
it?.anonymousId = " test"
1133
1128
it
0 commit comments