Search in sources :

Example 1 with EndpointProfile

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));
}
Also used : AnalyticsProperties(com.amplifyframework.analytics.AnalyticsProperties) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) AWSPinpointUserProfile(com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile) UserProfile(com.amplifyframework.analytics.UserProfile) AWSPinpointUserProfile(com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile) Test(org.junit.Test)

Example 2 with EndpointProfile

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"));
}
Also used : EndpointProfileUser(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) TargetingClient(com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient) Test(org.junit.Test)

Example 3 with EndpointProfile

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);
}
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 4 with EndpointProfile

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));
}
Also used : EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) List(java.util.List) Test(org.junit.Test)

Example 5 with EndpointProfile

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(), "");
    }
}
Also used : EndpointProfileUser(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) UpdateEndpointRequest(com.amazonaws.services.pinpoint.model.UpdateEndpointRequest) Test(org.junit.Test)

Aggregations

EndpointProfile (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile)13 Test (org.junit.Test)10 EndpointProfileUser (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser)3 AWSPinpointUserProfile (com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile)3 AnalyticsContextBuilder (com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder)2 MockDeviceDetails (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockDeviceDetails)2 AnalyticsProperties (com.amplifyframework.analytics.AnalyticsProperties)2 UserProfile (com.amplifyframework.analytics.UserProfile)2 List (java.util.List)2 Locale (java.util.Locale)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 Before (org.junit.Before)2 NotificationManager (android.app.NotificationManager)1 Context (android.content.Context)1 PinpointContext (com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext)1 TargetingClient (com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient)1 EndpointProfileDemographic (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileDemographic)1 EndpointProfileLocation (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileLocation)1 UpdateEndpointRequest (com.amazonaws.services.pinpoint.model.UpdateEndpointRequest)1 MissingResourceException (java.util.MissingResourceException)1