Search in sources :

Example 1 with TargetingClient

use of com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient 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 2 with TargetingClient

use of com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient 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);
}
Also used : Context(android.content.Context) PinpointContext(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext) SessionClient(com.amazonaws.mobileconnectors.pinpoint.analytics.SessionClient) AnalyticsContextBuilder(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder) ContextWithPermissions(com.amazonaws.mobileconnectors.pinpoint.analytics.utils.ContextWithPermissions) Activity(android.app.Activity) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) MockSystem(com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockSystem) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) AnalyticsClient(com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient) TargetingClient(com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient) AndroidPreferencesConfiguration(com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider)

Aggregations

TargetingClient (com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient)2 Activity (android.app.Activity)1 Context (android.content.Context)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)1 AnalyticsClient (com.amazonaws.mobileconnectors.pinpoint.analytics.AnalyticsClient)1 SessionClient (com.amazonaws.mobileconnectors.pinpoint.analytics.SessionClient)1 AnalyticsContextBuilder (com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder)1 ContextWithPermissions (com.amazonaws.mobileconnectors.pinpoint.analytics.utils.ContextWithPermissions)1 PinpointContext (com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext)1 AndroidPreferencesConfiguration (com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration)1 MockSystem (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockSystem)1 EndpointProfile (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile)1 EndpointProfileUser (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser)1 Test (org.junit.Test)1