Search in sources :

Example 1 with CustomerState

use of com.adobe.experiencecloud.ecid.visitor.CustomerState in project target-java-sdk by adobe.

the class TargetDeliveryRequestBuilder method setCustomerIds.

private void setCustomerIds() {
    if (CollectionUtils.isEmpty(visitorCustomerIds)) {
        return;
    }
    List<CustomerId> customerIds = new ArrayList<>();
    for (String integrationKey : visitorCustomerIds.keySet()) {
        CustomerState customerState = visitorCustomerIds.get(integrationKey);
        CustomerId customerId = new CustomerId().id(customerState.getId()).integrationCode(integrationKey);
        switch(customerState.getAuthState()) {
            case AUTHENTICATED:
                customerId.setAuthenticatedState(AuthenticatedState.AUTHENTICATED);
                break;
            case LOGGED_OUT:
                customerId.setAuthenticatedState(AuthenticatedState.LOGGED_OUT);
                break;
            default:
                customerId.setAuthenticatedState(AuthenticatedState.UNKNOWN);
                break;
        }
        customerIds.add(customerId);
    }
    targetCustomerIds = customerIds;
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) CustomerId(com.adobe.target.delivery.v1.model.CustomerId)

Example 2 with CustomerState

use of com.adobe.experiencecloud.ecid.visitor.CustomerState in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithCookies.

@Test
void testTargetDeliveryRequestWithCookies() throws NoSuchFieldException {
    setup(true);
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    Map<String, CustomerState> customerIds = getCustomerIds();
    List<Notification> mboxNotifications = getMboxNotifications();
    List<TargetCookie> testCookies = getTestCookies();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).customerIds(customerIds).notifications(mboxNotifications).trackingServer(TEST_TRACKING_SERVER).cookies(testCookies).thirdPartyId(TEST_THIRD_PARTY_ID).build();
    assertEquals(TEST_SESSION_ID, targetDeliveryRequest.getSessionId());
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
    verifyId(customerIds, targetDeliveryRequest);
    verifyVisitorValues(targetDeliveryRequest);
    verifyAnalyticsValues(targetDeliveryRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    verifyServerStateAndNewCookie(targetDeliveryResponse, TEST_SESSION_ID);
    verifyVisitorState(targetDeliveryResponse, customerIds);
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetCookie(com.adobe.target.edge.client.model.TargetCookie) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 3 with CustomerState

use of com.adobe.experiencecloud.ecid.visitor.CustomerState in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithoutCookies.

@Test
void testTargetDeliveryRequestWithoutCookies() throws NoSuchFieldException {
    setup(true);
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    Map<String, CustomerState> customerIds = getCustomerIds();
    List<Notification> mboxNotifications = getMboxNotifications();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).customerIds(customerIds).notifications(mboxNotifications).trackingServer(TEST_TRACKING_SERVER).thirdPartyId(TEST_THIRD_PARTY_ID).build();
    String newSessionId = targetDeliveryRequest.getSessionId();
    assertNotNull(newSessionId);
    VisitorId id = targetDeliveryRequest.getDeliveryRequest().getId();
    assertNull(id.getTntId());
    assertEquals(TEST_THIRD_PARTY_ID, id.getThirdPartyId());
    assertNull(id.getMarketingCloudVisitorId());
    validateCustomerId(customerIds, id.getCustomerIds());
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
    verifyAnalyticsValues(targetDeliveryRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    verifyServerStateAndNewCookie(targetDeliveryResponse, newSessionId);
    verifyVisitorState(targetDeliveryResponse, customerIds);
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 4 with CustomerState

use of com.adobe.experiencecloud.ecid.visitor.CustomerState in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method verifyVisitorState.

private void verifyVisitorState(TargetDeliveryResponse targetDeliveryResponse, Map<String, CustomerState> customerIdsExpected) {
    assertNotNull(targetDeliveryResponse.getVisitorState());
    assertEquals(1, targetDeliveryResponse.getVisitorState().size());
    VisitorState visitorState = targetDeliveryResponse.getVisitorState().get(TEST_ORG_ID);
    Map<String, CustomerState> customerIdsActual = visitorState.getCustomerIDs();
    assertEquals(customerIdsExpected, customerIdsActual);
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) VisitorState(com.adobe.experiencecloud.ecid.visitor.VisitorState)

Example 5 with CustomerState

use of com.adobe.experiencecloud.ecid.visitor.CustomerState in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithExpiredCookies.

@Test
void testTargetDeliveryRequestWithExpiredCookies() throws NoSuchFieldException {
    setup(true);
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    Map<String, CustomerState> customerIds = getCustomerIds();
    List<Notification> mboxNotifications = getMboxNotifications();
    List<TargetCookie> expiredSessionCookie = getExpiredSessionCookie();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).customerIds(customerIds).notifications(mboxNotifications).trackingServer(TEST_TRACKING_SERVER).cookies(expiredSessionCookie).thirdPartyId(TEST_THIRD_PARTY_ID).build();
    String newSessionId = targetDeliveryRequest.getSessionId();
    assertNotEquals(TEST_SESSION_ID, newSessionId);
    assertEquals(TEST_TNT_ID, targetDeliveryRequest.getDeliveryRequest().getId().getTntId());
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
    verifyAnalyticsValues(targetDeliveryRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    verifyServerStateAndNewCookie(targetDeliveryResponse, newSessionId);
    verifyVisitorState(targetDeliveryResponse, customerIds);
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetCookie(com.adobe.target.edge.client.model.TargetCookie) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Aggregations

CustomerState (com.adobe.experiencecloud.ecid.visitor.CustomerState)6 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)3 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)3 Test (org.junit.jupiter.api.Test)3 TargetCookie (com.adobe.target.edge.client.model.TargetCookie)2 VisitorState (com.adobe.experiencecloud.ecid.visitor.VisitorState)1 CustomerId (com.adobe.target.delivery.v1.model.CustomerId)1