Search in sources :

Example 1 with AnalyticsContextBuilder

use of com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder in project aws-sdk-android by aws-amplify.

the class AWSErsLocaleTestBase method setupForRepeatedTestCase.

@Override
public void setupForRepeatedTestCase() {
    Context mockAndroidContext = new ContextWithPermissions(new Activity());
    AWSCredentialsProvider provider = new AWSCredentialsProvider() {

        AWSCredentials creds = new AnonymousAWSCredentials();

        @Override
        public AWSCredentials getCredentials() {
            return creds;
        }

        @Override
        public void refresh() {
        }
    };
    mockConfiguration = mock(AndroidPreferencesConfiguration.class);
    PinpointConfiguration options = new PinpointConfiguration(mockAndroidContext, UNIQUE_ID, Regions.US_EAST_1, ChannelType.GCM, provider);
    context = new AnalyticsContextBuilder().withSdkInfo(SDK_NAME, SDK_VERSION).withUniqueIdValue(UNIQUE_ID).withContext(RuntimeEnvironment.application.getApplicationContext()).withSystem(new MockSystem("HELLO.world")).withConfiguration(mockConfiguration).build();
    AnalyticsClient analyticsClient = new AnalyticsClient(context);
    TargetingClient targetingClient = new TargetingClient(context);
    context.setAnalyticsClient(analyticsClient);
    context.setTargetingClient(targetingClient);
    SessionClient isc = new SessionClient(context);
    PinpointConfiguration config = new PinpointConfiguration(mockAndroidContext, UNIQUE_ID, Regions.US_EAST_1, ChannelType.GCM, provider);
    instance = new PinpointManager(config);
}
Also used : Context(android.content.Context) PinpointContext(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext) SessionClient(com.amazonaws.mobileconnectors.pinpoint.analytics.SessionClient) AnalyticsContextBuilder(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder) ContextWithPermissions(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.ContextWithPermissions) Activity(android.app.Activity) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) MockSystem(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockSystem) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) AnalyticsClient(com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient) TargetingClient(com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient) AndroidPreferencesConfiguration(com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider)

Example 2 with AnalyticsContextBuilder

use of com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder in project aws-sdk-android by aws-amplify.

the class AnalyticsEventTest method copyEvent_initializaer.

@Test
public void copyEvent_initializaer() {
    target.addAttribute("attr", "value");
    target.addMetric("metric", 1.0);
    PinpointContext mockContext = new AnalyticsContextBuilder().withSdkInfo(SDK_NAME, SDK_VERSION).withUniqueIdValue(UNIQUE_ID).withDeviceDetails(testDeviceDetails).withContext(RuntimeEnvironment.application.getApplicationContext()).build();
    AnalyticsEvent copiedTarget = AnalyticsEvent.createFromEvent(mockContext, SESSION_ID, System.currentTimeMillis(), target);
    assertEquals(EVENT_NAME, copiedTarget.getEventType());
    assertEquals(UNIQUE_ID, copiedTarget.getUniqueId());
    assertEquals(true, System.currentTimeMillis() - copiedTarget.getEventTimestamp() < 50);
    assertEquals(SDK_NAME, copiedTarget.getSdkName());
    assertEquals(SDK_VERSION, copiedTarget.getSdkVersion());
    assertEquals("value", copiedTarget.getAttribute("attr"));
    assertEquals(1.0, copiedTarget.getMetric("metric").doubleValue(), .01);
}
Also used : PinpointContext(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext) AnalyticsContextBuilder(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder) Test(org.junit.Test)

Example 3 with AnalyticsContextBuilder

use of com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder 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;
}
Also used : AndroidDeviceDetails(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidDeviceDetails) PinpointContext(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext) AndroidPreferencesConfiguration(com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration) AnalyticsContextBuilder(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder)

Example 4 with AnalyticsContextBuilder

use of com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder in project aws-sdk-android by aws-amplify.

the class EndpointProfileTest method setup.

@Before
public void setup() {
    testDeviceDetails = new MockDeviceDetails();
    mockContext = new AnalyticsContextBuilder().withSdkInfo(SDK_NAME, SDK_VERSION).withUniqueIdValue(UNIQUE_ID).withDeviceDetails(testDeviceDetails).withContext(RuntimeEnvironment.application.getApplicationContext()).build();
    target = new EndpointProfile(mockContext);
}
Also used : MockDeviceDetails(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockDeviceDetails) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) AnalyticsContextBuilder(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder) Before(org.junit.Before)

Example 5 with AnalyticsContextBuilder

use of com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder in project aws-sdk-android by aws-amplify.

the class TargetingClientTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    testDeviceDetails = new MockDeviceDetails();
    mockContext = new AnalyticsContextBuilder().withSdkInfo(SDK_NAME, SDK_VERSION).withUniqueIdValue(UNIQUE_ID).withDeviceDetails(testDeviceDetails).withPinpointServiceClient(mockPinpointServiceClient).withContext(RuntimeEnvironment.application.getApplicationContext()).build();
    targetingClient = new TargetingClient(mockContext, mockPinpointExecutor);
}
Also used : MockDeviceDetails(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockDeviceDetails) AnalyticsContextBuilder(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder) Before(org.junit.Before)

Aggregations

AnalyticsContextBuilder (com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder)19 Before (org.junit.Before)16 PinpointContext (com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext)14 AnalyticsClient (com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient)10 MockSystem (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockSystem)6 Context (android.content.Context)5 AnalyticsEvent (com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsEvent)5 MockDeviceDetails (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockDeviceDetails)5 AndroidPreferencesConfiguration (com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration)2 EndpointProfile (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile)2 Activity (android.app.Activity)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)1 SessionClient (com.amazonaws.mobileconnectors.pinpoint.analytics.SessionClient)1 ContextWithPermissions (com.amazonaws.mobileconnectors.pinpoint.analytics.utils.ContextWithPermissions)1 AndroidDeviceDetails (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidDeviceDetails)1 TargetingClient (com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient)1 Test (org.junit.Test)1