@@ -945,4 +945,35 @@ public void testIdentifiedEmailMergeTrue() throws Exception {
945
945
// check that email was set
946
946
assertEquals (email2 , IterableApi .getInstance ().getEmail ());
947
947
}
948
+
949
+ @ Test
950
+ public void testCriteriaMetTwice () throws Exception {
951
+ // clear any pending requests
952
+ while (server .takeRequest (1 , TimeUnit .SECONDS ) != null ) { }
953
+
954
+ // mock anon session response and track purchase response
955
+ addResponse (IterableConstants .ENDPOINT_TRACK_ANON_SESSION );
956
+ addResponse (IterableConstants .ENDPOINT_TRACK_PURCHASE );
957
+ addResponse (IterableConstants .ENDPOINT_TRACK_PURCHASE );
958
+
959
+ // trigger track purchase event
960
+ triggerTrackPurchaseEvent ("test" , "keyboard" , 4.67 , 3 );
961
+ triggerTrackPurchaseEvent ("test" , "keyboard" , 4.67 , 3 );
962
+ shadowOf (getMainLooper ()).idle ();
963
+
964
+ // check if only one request was sent to anon session endpoint
965
+ RecordedRequest anonSessionRequest = server .takeRequest (1 , TimeUnit .SECONDS );
966
+ assertNotNull ("Anon session request should not be null" , anonSessionRequest );
967
+ assertEquals ("/" + IterableConstants .ENDPOINT_TRACK_ANON_SESSION , anonSessionRequest .getPath ());
968
+
969
+ // check if first request was sent to track purchase endpoint
970
+ RecordedRequest firstPurchaseRequest = server .takeRequest (1 , TimeUnit .SECONDS );
971
+ assertNotNull ("Purchase request should not be null" , firstPurchaseRequest );
972
+ assertEquals ("/" + IterableConstants .ENDPOINT_TRACK_PURCHASE , firstPurchaseRequest .getPath ());
973
+
974
+ // check if second request was sent to track purchase endpoint
975
+ RecordedRequest secondPurchaseRequest = server .takeRequest (1 , TimeUnit .SECONDS );
976
+ assertNotNull ("Purchase request should not be null" , secondPurchaseRequest );
977
+ assertEquals ("/" + IterableConstants .ENDPOINT_TRACK_PURCHASE , secondPurchaseRequest .getPath ());
978
+ }
948
979
}
0 commit comments