use of com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient 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);
}
use of com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient in project aws-sdk-android by aws-amplify.
the class EventLocaleTest method createEvent_verifyLocaleFormat.
@Test
public void createEvent_verifyLocaleFormat() throws JSONException {
Map<String, Locale> locales = new HashMap<String, Locale>();
locales.put("en_US", Locale.US);
locales.put("en_CA", Locale.CANADA);
locales.put("fr_CA", Locale.CANADA_FRENCH);
locales.put("zh_CN", Locale.CHINA);
locales.put("fr_FR", Locale.FRANCE);
locales.put("de_DE", Locale.GERMANY);
locales.put("it_IT", Locale.ITALY);
locales.put("ja_JP", Locale.JAPAN);
locales.put("ko_KR", Locale.KOREA);
locales.put("zh_TW", Locale.TAIWAN);
locales.put("en_GB", Locale.UK);
locales.put("ar_SA", new Locale("ar", "SA"));
locales.put("nl_NL", new Locale("nl", "NL"));
locales.put("en_AU", new Locale("en", "AU"));
locales.put("es_ES", new Locale("es", "ES"));
locales.put("pt_BR", new Locale("pt", "BR"));
locales.put("es_MX", new Locale("es", "MX"));
for (String expectedLocaleName : locales.keySet()) {
Locale expectedLocale = locales.get(expectedLocaleName);
// create an event client
AnalyticsClient target = new AnalyticsClient(createMockContext(expectedLocale));
// create the event
AnalyticsEvent event = target.createEvent("localeEvent");
target.recordEvent(event);
JSONObject jsonEvent = event.toJSONObject();
assertThat(jsonEvent.getString("locale"), is(expectedLocaleName));
}
}
use of com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient in project aws-sdk-android by aws-amplify.
the class FCMNotificationClientTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
final Context roboContext = RuntimeEnvironment.application.getApplicationContext();
spiedRoboContext = Mockito.spy(roboContext);
mockPinpointContext = new AnalyticsContextBuilder().withSystem(new MockSystem("JIMMY_CRACKED_CORN.and")).withConfiguration(mockConfiguration).withContext(spiedRoboContext).build();
analyticsClient = new AnalyticsClient(mockPinpointContext);
Whitebox.setInternalState(analyticsClient, "eventRecorder", mockEventRecorder);
when(mockConfiguration.optBoolean("isAnalyticsEnabled", true)).thenReturn(true);
when(mockPinpointContext.getAnalyticsClient()).thenReturn(analyticsClient);
// target.setSessionClient(new SessionClient(mockContext, mockEventClient, mockTargetingClient,
// new TestSessionStore(), false));
when(mockPinpointContext.getTargetingClient()).thenReturn(mockTargetingClient);
when(mockPinpointContext.getConfiguration()).thenReturn(mockConfiguration);
when(mockPinpointContext.getPinpointConfiguration()).thenReturn(mockPinpointConfiguration);
target = NotificationClient.createClient(mockPinpointContext, ChannelType.GCM);
}
use of com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient in project aws-sdk-android by aws-amplify.
the class GCMNotificationClientTest method testGCMJourneyMessageReceivedDefaultDoNotPostNotificationInForeground.
@Test
public void testGCMJourneyMessageReceivedDefaultDoNotPostNotificationInForeground() throws JSONException {
// Force the app to be in the background
final AnalyticsEvent expectedEvent = new AnalyticsClient(mockPinpointContext).createEvent("_journey.received_background").withAttribute("journey_id", "fake_journey_id").withAttribute("journey_activity_id", "fake_journey_activity_id").withAttribute("journey_run_id", "fake_journey_run_id").withAttribute("feedback", "random_feedback").withAttribute("endpoint_id", "fake_endpoint_id").withAttribute("user_id", "fake_user_id").withAttribute("isOptedOut", "true").withAttribute("isAppInForeground", "false");
final AppUtil appUtil = Mockito.mock(AppUtil.class);
Whitebox.setInternalState(target.notificationClientBase, "appUtil", appUtil);
Mockito.when(appUtil.isAppInForeground()).thenReturn(false);
NotificationDetails.NotificationDetailsBuilder notificationDetailsBuilder = NotificationDetails.builder().from("12345").bundle(buildJourneyPushBundle()).serviceClass(Service.class).intentAction(GCM_INTENT_ACTION);
NotificationClient.PushResult pushResult = target.handleNotificationReceived(notificationDetailsBuilder.build());
assertEquals(NotificationClient.PushResult.OPTED_OUT, pushResult);
ArgumentCaptor<AnalyticsEvent> eventCaptor = ArgumentCaptor.forClass(AnalyticsEvent.class);
verify(mockEventRecorder, times(1)).recordEvent(eventCaptor.capture());
final AnalyticsEvent receivedEvent = eventCaptor.getAllValues().get(0);
assertTrue(receivedEvent.getEventTimestamp() > 0);
assertEquals("_journey.received_background", receivedEvent.getEventType());
assertEquals(expectedEvent.getAllAttributes(), receivedEvent.getAllAttributes());
}
use of com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient in project aws-sdk-android by aws-amplify.
the class GCMNotificationClientTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Context roboContext = ApplicationProvider.getApplicationContext();
spiedRoboContext = Mockito.spy(roboContext);
mockPinpointContext = new AnalyticsContextBuilder().withSystem(new MockSystem("JIMMY_CRACKED_CORN.and")).withConfiguration(mockConfiguration).withContext(spiedRoboContext).build();
analyticsClient = new AnalyticsClient(mockPinpointContext);
Whitebox.setInternalState(analyticsClient, "eventRecorder", mockEventRecorder);
when(mockConfiguration.optBoolean("isAnalyticsEnabled", true)).thenReturn(true);
when(mockPinpointContext.getAnalyticsClient()).thenReturn(analyticsClient);
// target.setSessionClient(new SessionClient(mockContext, mockEventClient, mockTargetingClient,
// new TestSessionStore(), false));
when(mockPinpointContext.getTargetingClient()).thenReturn(mockTargetingClient);
when(mockPinpointContext.getConfiguration()).thenReturn(mockConfiguration);
when(mockPinpointContext.getPinpointConfiguration()).thenReturn(mockPinpointConfiguration);
target = NotificationClient.createClient(mockPinpointContext, ChannelType.GCM);
}
Aggregations