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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations