use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileLocation in project aws-sdk-android by aws-amplify.
the class EndpointProfileTest method testProfile.
@Test
public void testProfile() {
assertTrue(target.getAllAttributes().isEmpty());
assertEquals(mockContext.getSystem().getAppDetails().getAppId(), target.getApplicationId());
assertEquals(UNIQUE_ID, target.getEndpointId());
assertEquals(mockContext.getSystem().getAppDetails().versionName(), target.getDemographic().getAppVersion());
assertEquals(mockContext.getApplicationContext().getResources().getConfiguration().locale.toString(), target.getDemographic().getLocale().toString());
assertEquals(mockContext.getSystem().getDeviceDetails().manufacturer(), target.getDemographic().getMake());
assertEquals(Build.MODEL, target.getDemographic().getModel());
assertEquals("ANDROID", target.getDemographic().getPlatform());
assertEquals(Build.VERSION.RELEASE, target.getDemographic().getPlatformVersion());
assertEquals(TimeZone.getDefault().getID(), target.getDemographic().getTimezone());
assertNotNull(target.getEffectiveDate());
assertNotNull(target.getLocation());
assertEquals(target.getOptOut(), "ALL");
assertNull(target.getAddress());
assertEquals(target.getDemographic().getPlatform(), "ANDROID");
assertEquals(target.getChannelType(), "GCM");
assertFalse(target.hasAttribute(""));
assertFalse(target.hasAttribute(null));
assertFalse(target.hasMetric(""));
assertFalse(target.hasMetric(null));
target.setDemographic(null);
assertNull(target.getDemographic());
target.setLocation(null);
assertNull(target.getLocation());
target.setEffectiveDate(0);
assertNotNull(target.getEffectiveDate());
target.setUser(null);
assertNull(target.getUser());
final EndpointProfileDemographic demographic = new EndpointProfileDemographic(mockContext);
demographic.setMake("test");
demographic.setModel("test");
demographic.setTimezone("test");
demographic.setLocale(new Locale("en", "US"));
demographic.setAppVersion("test");
demographic.setPlatform("test");
demographic.setPlatformVersion("test");
target.setDemographic(demographic);
assertEquals(demographic, target.getDemographic());
final EndpointProfileLocation location = new EndpointProfileLocation(mockContext);
location.setLatitude(0.0);
location.setLongitude(0.0);
location.setPostalCode("test");
location.setCity("test");
location.setRegion("test");
location.setCountry("test");
target.setLocation(location);
assertEquals(location, target.getLocation());
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileLocation in project aws-sdk-android by aws-amplify.
the class EndpointProfileTest method testCountryWithInvalidISO3Code.
@Test
public void testCountryWithInvalidISO3Code() {
Context mockApplicationContext = mock(Context.class);
android.content.res.Resources mockResources = mock(android.content.res.Resources.class);
android.content.res.Configuration mockConfiguration = mock(android.content.res.Configuration.class);
mockConfiguration.locale = new Locale("en", "CS");
Context mockedContext = mockContext.getApplicationContext().getApplicationContext();
when(mockResources.getConfiguration()).thenReturn(mockConfiguration);
when(mockApplicationContext.getResources()).thenReturn(mockResources);
when(mockApplicationContext.getApplicationContext()).thenReturn(mockedContext);
NotificationManager notificationManager = mock(NotificationManager.class);
when(mockApplicationContext.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager);
when(notificationManager.areNotificationsEnabled()).thenReturn(true);
when(mockContext.getApplicationContext()).thenReturn(mockApplicationContext);
final TargetingClient targetingClient = new TargetingClient(mockContext, mock(ThreadPoolExecutor.class));
final EndpointProfile endpointProfile = targetingClient.currentEndpoint();
String localeCountry;
try {
localeCountry = mockContext.getApplicationContext().getResources().getConfiguration().locale.getISO3Country();
} catch (final MissingResourceException exception) {
localeCountry = mockContext.getApplicationContext().getResources().getConfiguration().locale.getCountry();
}
final EndpointProfileLocation location = endpointProfile.getLocation();
assertTrue(location.getCountry().equalsIgnoreCase(localeCountry));
targetingClient.updateEndpointProfile(endpointProfile);
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileLocation in project amplify-android by aws-amplify.
the class AnalyticsPinpointInstrumentedTest method assertCommonEndpointProfileProperties.
private void assertCommonEndpointProfileProperties(EndpointProfile endpointProfile) {
EndpointProfileLocation endpointProfileLocation = endpointProfile.getLocation();
assertEquals("user@test.com", endpointProfile.getAttribute("email").get(0));
assertEquals("test-user", endpointProfile.getAttribute("name").get(0));
assertEquals("test-plan", endpointProfile.getAttribute("plan").get(0));
assertEquals((Double) 47.6154086, endpointProfileLocation.getLatitude());
assertEquals((Double) (-122.3349685), endpointProfileLocation.getLongitude());
assertEquals("98122", endpointProfileLocation.getPostalCode());
assertEquals("Seattle", endpointProfileLocation.getCity());
assertEquals("WA", endpointProfileLocation.getRegion());
assertEquals("USA", endpointProfileLocation.getCountry());
assertEquals("TestStringValue", endpointProfile.getAttribute("TestStringProperty").get(0));
assertEquals((Double) 1.0, endpointProfile.getMetric("TestDoubleProperty"));
}
Aggregations