@@ -1057,50 +1057,16 @@ class AsyncAnalyticsTests {
1057
1057
}
1058
1058
}
1059
1059
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
- }
1093
-
1094
1060
// @Test
1095
- // fun `startup queue should replay with group enrichment closure`() {
1061
+ // fun `startup queue should replay with identify enrichment closure`() {
1096
1062
// val expected = buildJsonObject {
1097
1063
// put("foo", "baz")
1098
1064
// }
1099
- // val expectedGroupId = "foo "
1065
+ // val expectedUserId = "newUserId "
1100
1066
//
1101
1067
// analytics.add(afterPlugin)
1102
- // analytics.group(expectedGroupId ) {
1103
- // if (it is GroupEvent ) {
1068
+ // analytics.identify(expectedUserId ) {
1069
+ // if (it is IdentifyEvent ) {
1104
1070
// it.traits = updateJsonObject(it.traits) {
1105
1071
// it["foo"] = "baz"
1106
1072
// }
@@ -1114,14 +1080,48 @@ class AsyncAnalyticsTests {
1114
1080
// // now we need to wait for events being fully replayed before making assertions
1115
1081
// assertSemaphore.acquire()
1116
1082
//
1083
+ // val actualUserId = analytics.userId()
1084
+ //
1117
1085
// assertTrue(actual.isCaptured)
1118
1086
// actual.captured.let {
1119
- // assertTrue(it is GroupEvent )
1120
- // val e = it as GroupEvent
1087
+ // assertTrue(it is IdentifyEvent )
1088
+ // val e = it as IdentifyEvent
1121
1089
// assertEquals(expected, e.traits)
1122
- // assertEquals(expectedGroupId, e.groupId )
1090
+ // assertEquals(expectedUserId, actualUserId )
1123
1091
// }
1124
1092
// }
1093
+
1094
+ @Test
1095
+ fun `startup queue should replay with group enrichment closure` () {
1096
+ val expected = buildJsonObject {
1097
+ put(" foo" , " baz" )
1098
+ }
1099
+ val expectedGroupId = " foo"
1100
+
1101
+ analytics.add(afterPlugin)
1102
+ analytics.group(expectedGroupId) {
1103
+ if (it is GroupEvent ) {
1104
+ it.traits = updateJsonObject(it.traits) {
1105
+ it[" foo" ] = " baz"
1106
+ }
1107
+ }
1108
+ it
1109
+ }
1110
+
1111
+ // now we have tracked event, i.e. event added to startup queue
1112
+ // release the semaphore put on http client, so we startup queue will replay the events
1113
+ httpSemaphore.release()
1114
+ // now we need to wait for events being fully replayed before making assertions
1115
+ assertSemaphore.acquire()
1116
+
1117
+ assertTrue(actual.isCaptured)
1118
+ actual.captured.let {
1119
+ assertTrue(it is GroupEvent )
1120
+ val e = it as GroupEvent
1121
+ assertEquals(expected, e.traits)
1122
+ assertEquals(expectedGroupId, e.groupId)
1123
+ }
1124
+ }
1125
1125
//
1126
1126
// @Test
1127
1127
// fun `startup queue should replay with alias enrichment closure`() {
0 commit comments