use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser 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.EndpointProfileUser 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(), "");
}
}
use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser in project amplify-android by aws-amplify.
the class AWSPinpointAnalyticsPlugin method identifyUser.
@Override
public void identifyUser(@NonNull String userId, @Nullable UserProfile userProfile) {
Objects.requireNonNull(userId);
EndpointProfile endpointProfile = targetingClient.currentEndpoint();
// Assign userId to the endpoint.
EndpointProfileUser user = new EndpointProfileUser();
user.setUserId(userId);
if (userProfile instanceof AWSPinpointUserProfile) {
AWSPinpointUserProfile pinpointUserProfile = (AWSPinpointUserProfile) userProfile;
if (pinpointUserProfile.getUserAttributes() != null) {
addUserAttributes(user, pinpointUserProfile.getUserAttributes());
}
}
endpointProfile.setUser(user);
// Add user-specific data to the endpoint
if (userProfile != null) {
addUserProfileToEndpoint(endpointProfile, userProfile);
}
// update endpoint
targetingClient.updateEndpointProfile(endpointProfile);
}
Aggregations