use of com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration in project aws-sdk-android by aws-amplify.
the class EventLocaleTest method createMockContext.
private static PinpointContext createMockContext(Locale localeToReturn) {
AndroidPreferencesConfiguration mockConfiguration = Mockito.mock(AndroidPreferencesConfiguration.class);
when(mockConfiguration.optString("versionKey", "ver")).thenReturn("ver");
when(mockConfiguration.optBoolean("isAnalyticsEnabled", true)).thenReturn(true);
AndroidDeviceDetails mockDeviceDetails = Mockito.mock(AndroidDeviceDetails.class);
when(mockDeviceDetails.locale()).thenReturn(localeToReturn);
PinpointContext mockContext = new AnalyticsContextBuilder().withSdkInfo(SDK_NAME, SDK_VERSION).withUniqueIdValue(UNIQUE_ID).withConfiguration(mockConfiguration).withDeviceDetails(mockDeviceDetails).withContext(RuntimeEnvironment.application.getApplicationContext()).build();
return mockContext;
}
use of com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration in project aws-sdk-android by aws-amplify.
the class EventRecorderTest method testProcessEvent_eventCount100.
@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);
// Note: Due to API there are (numberOfEvents + 1) added
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);
// Allows looping for next batch submit
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());
}
Aggregations