@@ -1057,50 +1057,16 @@ class AsyncAnalyticsTests {
10571057 }
10581058 }
10591059
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-
10941060// @Test
1095- // fun `startup queue should replay with group enrichment closure`() {
1061+ // fun `startup queue should replay with identify enrichment closure`() {
10961062// val expected = buildJsonObject {
10971063// put("foo", "baz")
10981064// }
1099- // val expectedGroupId = "foo "
1065+ // val expectedUserId = "newUserId "
11001066//
11011067// analytics.add(afterPlugin)
1102- // analytics.group(expectedGroupId ) {
1103- // if (it is GroupEvent ) {
1068+ // analytics.identify(expectedUserId ) {
1069+ // if (it is IdentifyEvent ) {
11041070// it.traits = updateJsonObject(it.traits) {
11051071// it["foo"] = "baz"
11061072// }
@@ -1114,14 +1080,48 @@ class AsyncAnalyticsTests {
11141080// // now we need to wait for events being fully replayed before making assertions
11151081// assertSemaphore.acquire()
11161082//
1083+ // val actualUserId = analytics.userId()
1084+ //
11171085// assertTrue(actual.isCaptured)
11181086// 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
11211089// assertEquals(expected, e.traits)
1122- // assertEquals(expectedGroupId, e.groupId )
1090+ // assertEquals(expectedUserId, actualUserId )
11231091// }
11241092// }
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+ }
11251125//
11261126// @Test
11271127// fun `startup queue should replay with alias enrichment closure`() {
0 commit comments