use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile in project amplify-android by aws-amplify.
the class AnalyticsPinpointInstrumentedTest method testIdentifyUserWithUserAtrributes.
/**
* {@link AWSPinpointUserProfile} extends {@link UserProfile} to include
* {@link AWSPinpointUserProfile#userAttributes} which is specific to Pinpoint. This test is very
* similar to testIdentifyUserWithDefaultProfile, but it adds user attributes in additional
* to the endpoint attributes.
*/
@Test
public void testIdentifyUserWithUserAtrributes() {
UserProfile.Location location = getTestLocation();
AnalyticsProperties properties = getEndpointProperties();
AnalyticsProperties userAttributes = getUserAttributes();
AWSPinpointUserProfile pinpointUserProfile = AWSPinpointUserProfile.builder().name("test-user").email("user@test.com").plan("test-plan").location(location).customProperties(properties).userAttributes(userAttributes).build();
Amplify.Analytics.identifyUser("userId", pinpointUserProfile);
EndpointProfile endpointProfile = targetingClient.currentEndpoint();
assertCommonEndpointProfileProperties(endpointProfile);
assertEquals("User attribute value", endpointProfile.getUser().getUserAttributes().get("SomeUserAttribute").get(0));
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile in project aws-sdk-android by aws-amplify.
the class EndpointProfileIntegrationTest method testEndpointProfileUpdate.
@Test
public void testEndpointProfileUpdate() {
TargetingClient targetingClient = pinpointManager.getTargetingClient();
assertNotNull(targetingClient);
targetingClient.updateEndpointProfile();
EndpointProfile endpointProfile = targetingClient.currentEndpoint();
assertNotNull(endpointProfile);
assertNull(endpointProfile.getUser().getUserId());
assertNull(endpointProfile.getUser().getUserAttributes());
EndpointProfileUser user = new EndpointProfileUser();
user.setUserId(credentialsProvider.getIdentityId());
user.addUserAttribute("user-key", Collections.singletonList("user-value"));
endpointProfile.setUser(user);
targetingClient.updateEndpointProfile();
endpointProfile = targetingClient.currentEndpoint();
assertNotNull(endpointProfile);
assertEquals(credentialsProvider.getIdentityId(), endpointProfile.getUser().getUserId());
assertNotNull(endpointProfile.getUser().getUserAttributes());
assertEquals(Collections.singletonMap("user-key", Collections.singletonList("user-value")), endpointProfile.getUser().getUserAttributes());
endpointProfile.addAttribute("key", Collections.singletonList("value"));
targetingClient.updateEndpointProfile();
endpointProfile = targetingClient.currentEndpoint();
assertNotNull(endpointProfile);
assertEquals(credentialsProvider.getIdentityId(), endpointProfile.getUser().getUserId());
assertEquals(Collections.singletonList("value"), endpointProfile.getAllAttributes().get("key"));
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile 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);
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile in project aws-sdk-android by aws-amplify.
the class TargetingClientTest method endpoint_globalAttributeAndMetricsAddedAfterEndpointCreation.
@Test
public void endpoint_globalAttributeAndMetricsAddedAfterEndpointCreation() {
final EndpointProfile endpointProfile = targetingClient.currentEndpoint();
final List attrVals = Arrays.asList(new String[] { "attr1", "attr2" });
endpointProfile.withAttribute(null, null).withMetric(null, null).withAttribute("attr", attrVals).withMetric("metric", 1.0);
assertThat(endpointProfile.getAllAttributes().size(), is(1));
assertThat(endpointProfile.getAllMetrics().size(), is(1));
assertThat(endpointProfile.getAttribute("attr"), is(attrVals));
assertThat(endpointProfile.getMetric("metric").intValue(), is(1));
endpointProfile.withAttribute("attr", null).withMetric("metric", null);
assertThat(endpointProfile.getAllAttributes().size(), is(0));
assertThat(endpointProfile.getAllMetrics().size(), is(0));
targetingClient.addAttribute("globalAttr", attrVals);
targetingClient.addMetric("globalMetric", 100.0);
targetingClient.currentEndpoint();
assertThat(targetingClient.currentEndpoint().getAllAttributes().size(), is(1));
assertThat(targetingClient.currentEndpoint().getAllMetrics().size(), is(1));
assertThat(targetingClient.currentEndpoint().getAttribute("globalAttr"), is(attrVals));
assertThat(targetingClient.currentEndpoint().getMetric("globalMetric").intValue(), is(100));
targetingClient.removeMetric(null);
targetingClient.removeMetric("globalMetric");
targetingClient.removeAttribute(null);
targetingClient.removeAttribute("globalAttr");
assertThat(targetingClient.currentEndpoint().getAllAttributes().size(), is(0));
assertThat(targetingClient.currentEndpoint().getAllMetrics().size(), is(0));
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile in project aws-sdk-android by aws-amplify.
the class TargetingClientTest method updateEndpointEmptyUserId.
@Test
public void updateEndpointEmptyUserId() {
final ArgumentCaptor<UpdateEndpointRequest> requestArgumentCaptor = ArgumentCaptor.forClass(UpdateEndpointRequest.class);
EndpointProfile endpointProfile = new EndpointProfile(mockContext);
EndpointProfileUser user = new EndpointProfileUser();
user.setUserId("");
endpointProfile.setUser(user);
targetingClient.updateEndpointProfile(endpointProfile);
verifyAndRunExecutorService(1);
verify(mockPinpointServiceClient, times(1)).updateEndpoint(requestArgumentCaptor.capture());
for (final UpdateEndpointRequest request : requestArgumentCaptor.getAllValues()) {
assertNotNull(request.getEndpointRequest().getUser());
assertEquals(request.getEndpointRequest().getUser().getUserId(), "");
}
}
Aggregations