@@ -199,6 +199,64 @@ class FlagshipTestsHits : AFlagshipTest() {
199199 }
200200 }
201201
202+ @Test
203+ fun test_segment_hit () {
204+ //
205+ val jsonResponse =
206+ FlagshipTestsHelper .jsonObjectFromAssets(getApplication(), " bucketing_response_3.json" )
207+ jsonResponse
208+ .getJSONObject(" accountSettings" )
209+
210+ FlagshipTestsHelper .interceptor().intercept(
211+ BUCKETING_URL .format(_ENV_ID_ ),
212+ FlagshipTestsHelper .responseFromString(getApplication(), jsonResponse.toString(), 200 )
213+ )
214+ .intercept(
215+ ARIANE_URL .format(_ENV_ID_ ),
216+ FlagshipTestsHelper .response(" " , 200 )
217+ )
218+
219+ runBlocking {
220+ Flagship .start(
221+ getApplication(),
222+ _ENV_ID_ ,
223+ _API_KEY_ ,
224+ FlagshipConfig .Bucketing ().withTrackingManagerConfig(
225+ TrackingManagerConfig (disablePolling = true )
226+ )
227+ ).await()
228+ }
229+
230+ val visitor = Flagship .newVisitor(" visitor_1" , true )
231+ .context(hashMapOf(
232+ " boolValue" to true ,
233+ " doubleValue" to 3.14 ,
234+ " stringValue" to " string" ,
235+ " intValue" to 434 ,
236+ " jsonValue" to JSONObject (" {}" )
237+ ))
238+ .build()
239+ Thread .sleep(100 )
240+ visitor.fetchFlags()
241+ Thread .sleep(100 )
242+ FlagshipTestsHelper .interceptor().calls[ARIANE_URL ]?.get(1 )?.let {
243+ val jsonHit = HttpCompat .requestJson(it.first)
244+ Assert .assertEquals(" BATCH" , jsonHit.getString(" t" ))
245+ Assert .assertEquals(_ENV_ID_ , jsonHit.getString(" cid" ))
246+ Assert .assertEquals(" APP" , jsonHit.getString(" ds" ))
247+ val content = jsonHit.getJSONArray(" h" ).getJSONObject(0 )
248+ Assert .assertEquals(content.getString(" vid" ), " visitor_1" )
249+ Assert .assertEquals(content.getString(" ds" ), " APP" )
250+ Assert .assertEquals(content.get(" t" ), " SEGMENT" )
251+ Assert .assertEquals(content.getJSONObject(" s" ).get(" boolValue" ), " true" )
252+ Assert .assertEquals(content.getJSONObject(" s" ).get(" doubleValue" ), " 3.14" )
253+ Assert .assertEquals(content.getJSONObject(" s" ).get(" stringValue" ), " string" )
254+ Assert .assertEquals(content.getJSONObject(" s" ).get(" intValue" ), " 434" )
255+ Assert .assertFalse(content.getJSONObject(" s" ).has(" jsonValue" ))
256+ // Assert.assertEquals(content.get("dl"), "https://location.com")
257+ }
258+ }
259+
202260 @Test
203261 fun test_event_hit () {
204262
@@ -1044,6 +1102,7 @@ class FlagshipTestsHits : AFlagshipTest() {
10441102 FlagshipTestsHelper .interceptor().calls[TROUBLESHOOTING_URL ]?.size
10451103 ) // 1 Bucketing, 1 Fetch, 1 Segment, 1 consent
10461104
1105+
10471106 FlagshipTestsHelper .interceptor().calls[TROUBLESHOOTING_URL ]!! [0 ].let {
10481107 val jsonHit = HttpCompat .requestJson(it.first)
10491108 val cv = jsonHit.getJSONObject(CUSTOM_VALUE )
0 commit comments