use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TelemetryServiceTest method testAddTelemetry.
/**
* Verify if telemetry data is added correctly
*
* @throws NoSuchFieldException
*/
@Test
void testAddTelemetry() throws NoSuchFieldException {
setup(true, DecisioningMethod.SERVER_SIDE, "testAddTelemetry");
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
String nonDefaultToken = "non-default-token";
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
targetDeliveryResponse.getResponse().setRequestId("testID");
// empty the in memory stored telemetry
telemetryServiceSpy.getTelemetry();
assertEquals(0, telemetryServiceSpy.getTelemetry().getEntries().size());
telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TelemetryServiceTest method testExecutionModeForOnDevice.
/**
* Test to verify telemetryEntry has correct executionMode For ODD & status 200 it should be local
*
* @throws NoSuchFieldException
*/
@Test
void testExecutionModeForOnDevice() throws NoSuchFieldException {
setup(true, DecisioningMethod.ON_DEVICE, "testExecutionModeOnDeviceWhenStatusOK");
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
String nonDefaultToken = "non-default-token";
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.ON_DEVICE).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
targetDeliveryResponse.getResponse().setRequestId("testID");
telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
TelemetryEntry telemetryEntry = telemetryServiceSpy.getTelemetry().getEntries().get(1);
assert telemetryEntry != null;
assertEquals(ExecutionMode.LOCAL, telemetryEntry.getMode());
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestTest method testTelemetryForServerSide.
@Test
void testTelemetryForServerSide() throws NoSuchFieldException {
setup(true);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
String nonDefaultToken = "non-default-token";
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
targetJavaClient.getOffers(targetDeliveryRequest);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
assertNotNull(targetDeliveryResponse);
assertNotNull(targetDeliveryResponse.getRequest());
assertNotNull(targetDeliveryResponse.getRequest().getTelemetry());
assertEquals(1, targetDeliveryResponse.getRequest().getTelemetry().getEntries().size());
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse 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);
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestOutTimeRange.
@Test
void testTargetDeliveryLocalRequestOutTimeRange() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_TIMEFRAME.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873", DecisioningMethod.HYBRID, "daterange-mbox");
ParamsCollator specificTimeCollator = TargetTestDeliveryRequestUtils.getSpecificTimeCollator(1590516000000L);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "daterange-mbox");
verifyHTMLContent(prefetchOptions, "<strong>default result</strong>", "wQY/V1IOYec8T4fAT5ww7mqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
Aggregations