### Question:
EventRecorder { JSONArray getBatchOfEvents(final Cursor cursor, final HashMap<Integer, Integer> idsAndSizeToDelete) { final JSONArray eventArray = new JSONArray(); long currentRequestSize = 0; long eventLength; final long maxRequestSize = pinpointContext .getConfiguration() .optLong(KEY_MAX_SUBMISSION_SIZE, DEFAULT_MAX_SUBMISSION_SIZE); do { JSONObject json = readEventFromCursor(cursor, idsAndSizeToDelete); if (json != null) { eventLength = json.length(); currentRequestSize += eventLength; eventArray.put(json); } if (currentRequestSize > maxRequestSize || eventArray.length() >= SERVICE_DEFINED_MAX_EVENTS_PER_BATCH) { break; } } while (cursor.moveToNext()); return eventArray; } EventRecorder(final PinpointContext pinpointContext,
                  final PinpointDBUtil dbUtil,
                  final ExecutorService submissionRunnableQueue); static EventRecorder newInstance(final PinpointContext pinpointContext); static EventRecorder newInstance(final PinpointContext pinpointContext, final PinpointDBUtil dbUtil); static void setClippedEventLength(final int clippedEventLength); void closeDB(); Uri recordEvent(final AnalyticsEvent event); void submitEvents(); List<JSONObject> getAllEvents();  }### Answer:
@Test public void testProcessEvent_eventCount100() { PinpointDBUtil dbUtil = mock(PinpointDBUtil.class); PinpointContext pinpointContext = mock(PinpointContext.class); EventRecorder eventRecorder = new EventRecorder(pinpointContext, dbUtil, mock(ExecutorService.class)); AndroidPreferencesConfiguration config = mock(AndroidPreferencesConfiguration.class); when(pinpointContext.getConfiguration()).thenReturn(config); when(config.optLong(any(String.class), any(Long.class))).thenReturn(5 * 1024 * 1024L); Cursor cursor = mock(Cursor.class); int numberOfEvents = 150; Boolean[] falseArray = new Boolean[numberOfEvents]; Arrays.fill(falseArray, false); int sharedIdForAllEvents = 1; Integer[] idArray = new Integer[numberOfEvents]; Arrays.fill(idArray, sharedIdForAllEvents); int size = 2; Integer[] sizeArray = new Integer[numberOfEvents]; Arrays.fill(sizeArray, size); String[] jsonStringArray = new String[numberOfEvents]; String json = "{}"; Arrays.fill(jsonStringArray, json); when(cursor.isNull(EventTable.COLUMN_INDEX.ID.getValue())).thenReturn(false, falseArray); when(cursor.getInt(EventTable.COLUMN_INDEX.ID.getValue())).thenReturn(sharedIdForAllEvents, idArray); when(cursor.isNull(EventTable.COLUMN_INDEX.SIZE.getValue())).thenReturn(false, falseArray); when(cursor.getInt(EventTable.COLUMN_INDEX.SIZE.getValue())).thenReturn(size, sizeArray); when(cursor.isNull(EventTable.COLUMN_INDEX.JSON.getValue())).thenReturn(false, falseArray); when(cursor.getString(EventTable.COLUMN_INDEX.JSON.getValue())).thenReturn(json, jsonStringArray); when(cursor.moveToNext()).thenReturn(true).thenReturn(true).thenReturn(true); JSONArray readArray = eventRecorder.getBatchOfEvents(cursor, new HashMap<Integer, Integer>()); assertEquals(EventRecorder.SERVICE_DEFINED_MAX_EVENTS_PER_BATCH, readArray.length()); }