use of com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockAppDetails in project aws-sdk-android by aws-amplify.
the class EventRecorderTest method testRecordEventPayload.
@Test
public void testRecordEventPayload() throws JSONException {
final Event event = new Event();
eventRecorder.buildEventPayload(analyticsEvent, event);
final MockAppDetails mockAppDetails = new MockAppDetails();
assertEquals(mockAppDetails.packageName(), event.getAppPackageName());
assertEquals(mockAppDetails.getAppTitle(), event.getAppTitle());
assertEquals(mockAppDetails.versionCode(), event.getAppVersionCode());
assertEquals(EVENT_NAME, event.getEventType());
assertEquals(SDK_NAME, event.getSdkName());
assertEquals(SDK_VERSION, event.getClientSdkVersion());
assertNotNull(event.getAttributes());
assertTrue(event.getAttributes().equals(analyticsEvent.getAllAttributes()));
assertEquals(event.getAttributes().get("key1"), "value1");
assertEquals(event.getAttributes().get("key2"), "value2");
assertNotNull(event.getMetrics());
assertNotNull(event.getSession());
}
use of com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockAppDetails in project aws-sdk-android by aws-amplify.
the class AnalyticsContextBuilder method build.
public PinpointContext build() {
final SDKInfo mockSDKInfo = mock(SDKInfo.class);
when(mockSDKInfo.getName()).thenReturn(sdkName);
when(mockSDKInfo.getVersion()).thenReturn(sdkVersion);
final MockUtil mockUtil = new MockUtil();
if (mockUtil.isMock(mockSystem)) {
when(mockSystem.getPreferences()).thenReturn(mockPreferences);
when(mockSystem.getConnectivity()).thenReturn(mockConnectivity);
final AndroidAppDetails mockAppDetails = new MockAppDetails();
when(mockSystem.getAppDetails()).thenReturn(mockAppDetails);
when(mockSystem.getDeviceDetails()).thenReturn(mockDeviceDetails);
}
final PinpointContext mockContext = mock(PinpointContext.class);
when(mockContext.getSDKInfo()).thenReturn(mockSDKInfo);
when(mockContext.getConfiguration()).thenReturn(mockConfig);
when(mockContext.getUniqueId()).thenReturn(mockUniqueIdValue);
when(mockContext.getAnalyticsServiceClient()).thenReturn(mockERS);
when(mockContext.getPinpointServiceClient()).thenReturn(mockPinpointService);
when(mockContext.getSystem()).thenReturn(mockSystem);
// Notification client must be constructed after mock system is set
mockNotificationClient = new NotificationClient(mockContext);
when(mockContext.getNotificationClient()).thenReturn(mockNotificationClient);
when(mockContext.getApplicationContext()).thenReturn(context);
when(mockContext.getConfiguration()).thenReturn(mockConfig);
when(mockContext.getNetworkType()).thenCallRealMethod();
when(mockContext.getTargetingClient()).thenReturn(mockTargetingClient);
when(mockContext.getPinpointConfiguration()).thenReturn(mockPinpointConfig);
return mockContext;
}
Aggregations