@@ -211,18 +211,18 @@ public void testRemoveIrrelevantBackgroundStartRequests() throws NoSuchMethodExc
211211 LeanplumEventDataManagerTest .setDatabaseToNull ();
212212 }
213213
214- // Given a list of unsent requests
215- // we want to get the list of strings to send
216- // We should get back the correct list of requests to send
214+ // Given a list of 5000 that generate OOM exceptions
215+ // we want to generate the requests to send
216+ // The list should try and get a smaller fraction of the available requests
217217 @ Test
218218 public void testJsonEncodeUnsentRequestsWithExceptionLargeNumbers () throws NoSuchMethodException ,
219219 InvocationTargetException , IllegalAccessException {
220220 LeanplumEventDataManager .init (Leanplum .getContext ());
221221 Request .RequestsWithEncoding requestsWithEncoding ;
222222 // Prepare testable objects and method.
223223 Request request = spy (new Request ("POST" , Constants .Methods .START , null ));
224- request .sendEventually ();
225- for (int i = 0 ;i < 4999 ; i ++) {
224+ request .sendEventually (); // first request added
225+ for (int i = 0 ;i < 4999 ; i ++) { // remaining requests to make up 5000
226226 new Request ("POST" , Constants .Methods .START , null ).sendEventually ();
227227 }
228228 // Expectation: 5000 requests returned.
@@ -264,6 +264,9 @@ public void testJsonEncodeUnsentRequestsWithExceptionLargeNumbers() throws NoSuc
264264
265265 }
266266
267+ // Given a list of unsent requests that generate an OOM exception
268+ // we want to generate the requests to send
269+ // The list should try and get a smaller fraction of the available requests
267270 @ Test
268271 public void testJsonEncodeUnsentRequestsWithException () {
269272 List <Map <String , Object >> requests = mockRequests (4 );
@@ -282,9 +285,10 @@ public void testJsonEncodeUnsentRequestsWithException() {
282285 assertEquals (expectedJson , requestsWithEncoding .jsonEncodedString );
283286 }
284287
285- // Given a list of requests
286- // we want to encode to a JSON String
287- // The String should have the expected format
288+ // Given a list of unsent requests
289+ // we want to generate the requests to send
290+ // The String should have the expected format, and the request count should be equal to the
291+ // number of unsent requests
288292 @ Test
289293 public void testJsonEncodeUnsentRequests () {
290294 List <Map <String , Object >> requests = mockRequests (4 );
@@ -294,9 +298,16 @@ public void testJsonEncodeUnsentRequests() {
294298 when (request .getUnsentRequests (1.0 )).thenReturn (requests );
295299
296300 Request .RequestsWithEncoding requestsWithEncoding = request .getRequestsWithEncodedStringStoredRequests (1.0 );
301+
302+ assertEquals (4 , requestsWithEncoding .unsentRequests .size ());
303+ assertEquals (4 , requestsWithEncoding .requestsToSend .size ());
297304 final String expectedJson = "{\" data\" :[{\" 0\" :\" testData\" },{\" 1\" :\" testData\" },{\" 2\" :\" testData\" },{\" 3\" :\" testData\" }]}" ;
298305 assertEquals (expectedJson , requestsWithEncoding .jsonEncodedString );
299306 }
307+
308+ // Given a list of requests
309+ // we want to encode to a JSON String
310+ // The String should have the expected format
300311 @ Test
301312 public void testGetRequestsWithEncodedStringStoredRequests () {
302313 List <Map <String , Object >> requests = mockRequests (4 );
0 commit comments