Search in sources :

Example 1 with MockAppDetails

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());
}
Also used : MockAppDetails(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockAppDetails) AnalyticsEvent(com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsEvent) Event(com.amazonaws.services.pinpoint.model.Event) Test(org.junit.Test)

Example 2 with MockAppDetails

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;
}
Also used : MockAppDetails(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockAppDetails) PinpointContext(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext) AndroidAppDetails(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidAppDetails) MockUtil(org.mockito.internal.util.MockUtil) SDKInfo(com.amazonaws.mobileconnectors.pinpoint.internal.core.util.SDKInfo) NotificationClient(com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient)

Aggregations

MockAppDetails (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockAppDetails)2 AnalyticsEvent (com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsEvent)1 PinpointContext (com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext)1 AndroidAppDetails (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidAppDetails)1 SDKInfo (com.amazonaws.mobileconnectors.pinpoint.internal.core.util.SDKInfo)1 NotificationClient (com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient)1 Event (com.amazonaws.services.pinpoint.model.Event)1 Test (org.junit.Test)1 MockUtil (org.mockito.internal.util.MockUtil)1