@@ -96,23 +96,23 @@ public void dispatchEventsInCorrectNumberOfBatches() throws InterruptedException
9696 public void dispatchEventsWithCorrectPayload () throws InterruptedException {
9797 Mockito .reset (mockApiManager );
9898 Mockito .when (mockApiManager .sendEvents (any (), any (), any ())).thenReturn (202 );
99- int batchSize = 2 ;
99+ int flushInterval = 0 ;
100100 ODPConfig odpConfig = new ODPConfig ("key" , "http://www.odp-host.com" , null );
101- ODPEventManager eventManager = new ODPEventManager (mockApiManager , batchSize , null , null );
101+ ODPEventManager eventManager = new ODPEventManager (mockApiManager , null , flushInterval );
102102 eventManager .updateSettings (odpConfig );
103103 eventManager .start ();
104104 for (int i = 0 ; i < 6 ; i ++) {
105105 eventManager .sendEvent (getEvent (i ));
106106 }
107107 Thread .sleep (500 );
108- Mockito .verify (mockApiManager , times (3 )).sendEvents (eq ("key" ), eq ("http://www.odp-host.com/v3/events" ), payloadCaptor .capture ());
108+ Mockito .verify (mockApiManager , times (6 )).sendEvents (eq ("key" ), eq ("http://www.odp-host.com/v3/events" ), payloadCaptor .capture ());
109109 List <String > payloads = payloadCaptor .getAllValues ();
110110
111111 for (int i = 0 ; i < payloads .size (); i ++) {
112112 JSONArray events = new JSONArray (payloads .get (i ));
113- assertEquals (batchSize , events .length ());
113+ assertEquals (1 , events .length ());
114114 for (int j = 0 ; j < events .length (); j ++) {
115- int id = (batchSize * i ) + j ;
115+ int id = (1 * i ) + j ;
116116 JSONObject event = events .getJSONObject (j );
117117 assertEquals ("test-type-" + id , event .getString ("type" ));
118118 assertEquals ("test-action-" + id , event .getString ("action" ));
@@ -186,27 +186,27 @@ public void shouldFlushAllScheduledEventsBeforeStopping() throws InterruptedExce
186186 public void prepareCorrectPayloadForIdentifyUser () throws InterruptedException {
187187 Mockito .reset (mockApiManager );
188188 Mockito .when (mockApiManager .sendEvents (any (), any (), any ())).thenReturn (202 );
189- int batchSize = 2 ;
189+ int flushInterval = 0 ;
190190 ODPConfig odpConfig = new ODPConfig ("key" , "http://www.odp-host.com" , null );
191- ODPEventManager eventManager = new ODPEventManager (mockApiManager , batchSize , null , null );
191+ ODPEventManager eventManager = new ODPEventManager (mockApiManager , null , flushInterval );
192192 eventManager .updateSettings (odpConfig );
193193 eventManager .start ();
194194 for (int i = 0 ; i < 2 ; i ++) {
195195 eventManager .identifyUser ("the-vuid-" + i , "the-fs-user-id-" + i );
196196 }
197197
198198 Thread .sleep (1500 );
199- Mockito .verify (mockApiManager , times (1 )).sendEvents (eq ("key" ), eq ("http://www.odp-host.com/v3/events" ), payloadCaptor .capture ());
199+ Mockito .verify (mockApiManager , times (2 )).sendEvents (eq ("key" ), eq ("http://www.odp-host.com/v3/events" ), payloadCaptor .capture ());
200200
201201 String payload = payloadCaptor .getValue ();
202202 JSONArray events = new JSONArray (payload );
203- assertEquals (batchSize , events .length ());
203+ assertEquals (1 , events .length ());
204204 for (int i = 0 ; i < events .length (); i ++) {
205205 JSONObject event = events .getJSONObject (i );
206206 assertEquals ("fullstack" , event .getString ("type" ));
207207 assertEquals ("identified" , event .getString ("action" ));
208- assertEquals ("the-vuid-" + i , event .getJSONObject ("identifiers" ).getString ("vuid" ));
209- assertEquals ("the-fs-user-id-" + i , event .getJSONObject ("identifiers" ).getString ("fs_user_id" ));
208+ assertEquals ("the-vuid-" + ( i + 1 ) , event .getJSONObject ("identifiers" ).getString ("vuid" ));
209+ assertEquals ("the-fs-user-id-" + ( i + 1 ) , event .getJSONObject ("identifiers" ).getString ("fs_user_id" ));
210210 assertEquals ("sdk" , event .getJSONObject ("data" ).getString ("data_source_type" ));
211211 }
212212 }
0 commit comments