@@ -96,23 +96,23 @@ public void dispatchEventsInCorrectNumberOfBatches() throws InterruptedException
96
96
public void dispatchEventsWithCorrectPayload () throws InterruptedException {
97
97
Mockito .reset (mockApiManager );
98
98
Mockito .when (mockApiManager .sendEvents (any (), any (), any ())).thenReturn (202 );
99
- int batchSize = 2 ;
99
+ int flushInterval = 0 ;
100
100
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 );
102
102
eventManager .updateSettings (odpConfig );
103
103
eventManager .start ();
104
104
for (int i = 0 ; i < 6 ; i ++) {
105
105
eventManager .sendEvent (getEvent (i ));
106
106
}
107
107
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 ());
109
109
List <String > payloads = payloadCaptor .getAllValues ();
110
110
111
111
for (int i = 0 ; i < payloads .size (); i ++) {
112
112
JSONArray events = new JSONArray (payloads .get (i ));
113
- assertEquals (batchSize , events .length ());
113
+ assertEquals (1 , events .length ());
114
114
for (int j = 0 ; j < events .length (); j ++) {
115
- int id = (batchSize * i ) + j ;
115
+ int id = (1 * i ) + j ;
116
116
JSONObject event = events .getJSONObject (j );
117
117
assertEquals ("test-type-" + id , event .getString ("type" ));
118
118
assertEquals ("test-action-" + id , event .getString ("action" ));
@@ -186,27 +186,27 @@ public void shouldFlushAllScheduledEventsBeforeStopping() throws InterruptedExce
186
186
public void prepareCorrectPayloadForIdentifyUser () throws InterruptedException {
187
187
Mockito .reset (mockApiManager );
188
188
Mockito .when (mockApiManager .sendEvents (any (), any (), any ())).thenReturn (202 );
189
- int batchSize = 2 ;
189
+ int flushInterval = 0 ;
190
190
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 );
192
192
eventManager .updateSettings (odpConfig );
193
193
eventManager .start ();
194
194
for (int i = 0 ; i < 2 ; i ++) {
195
195
eventManager .identifyUser ("the-vuid-" + i , "the-fs-user-id-" + i );
196
196
}
197
197
198
198
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 ());
200
200
201
201
String payload = payloadCaptor .getValue ();
202
202
JSONArray events = new JSONArray (payload );
203
- assertEquals (batchSize , events .length ());
203
+ assertEquals (1 , events .length ());
204
204
for (int i = 0 ; i < events .length (); i ++) {
205
205
JSONObject event = events .getJSONObject (i );
206
206
assertEquals ("fullstack" , event .getString ("type" ));
207
207
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" ));
210
210
assertEquals ("sdk" , event .getJSONObject ("data" ).getString ("data_source_type" ));
211
211
}
212
212
}
0 commit comments