use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class DefaultTargetServiceTest method getDeliveryRequest.
private TargetDeliveryRequest getDeliveryRequest() {
Context context = getLocalContext();
PrefetchRequest prefetchRequest = getMboxPrefetchLocalRequest("testoffer");
ExecuteRequest executeRequest = getMboxExecuteLocalRequest("testoffer2");
VisitorId visitorId = new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916873");
Notification notification = new Notification();
notification.setId(UUID.randomUUID().toString());
notification.setImpressionId(UUID.randomUUID().toString());
notification.setType(MetricType.DISPLAY);
notification.setTimestamp(System.currentTimeMillis());
notification.setTokens(Collections.singletonList("IbG2Jz2xmHaqX7Ml/YRxRGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).id(visitorId).notifications(Collections.singletonList(notification)).build();
return targetDeliveryRequest;
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testTelemetryForServerSide.
/**
* Test case to call get offers for server side, in first request we capture the telemetry & in
* next call we send it with any getOffers() call or sendNotifications() call
*
* @throws NoSuchFieldException
*/
@Test
void testTelemetryForServerSide() throws NoSuchFieldException {
setup(true, DecisioningMethod.SERVER_SIDE, "testTelemetryForServerSide");
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();
TargetDeliveryResponse targetDeliveryResponse1 = targetJavaClient.getOffers(targetDeliveryRequest);
assertNull(targetDeliveryResponse1.getRequest().getTelemetry());
// In next call we see telemetry data added to the deliveryRequest
TargetDeliveryResponse targetDeliveryResponse2 = targetJavaClient.getOffers(targetDeliveryRequest);
verify(telemetryServiceSpy, atLeast(2)).getTelemetry();
verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
assertNotNull(targetDeliveryResponse2);
assertNotNull(targetDeliveryResponse2.getRequest());
assertNotNull(targetDeliveryResponse2.getRequest().getTelemetry());
assertEquals(1, targetDeliveryResponse2.getRequest().getTelemetry().getEntries().size());
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testAddTelemetryForServerSide.
/**
* Checking all telemetryEntry features which gets added for server side decisioning
*
* @throws NoSuchFieldException
*/
@Test
void testAddTelemetryForServerSide() throws NoSuchFieldException {
setup(true, DecisioningMethod.SERVER_SIDE, "testAddTelemetryForServerSide");
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");
deliveryResponse.setEdgeHost("mboxedge35.tt.omtrdc.net");
TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
targetDeliveryResponse.getResponse().setRequestId("testID");
targetDeliveryResponse.getResponse().setTelemetryServerToken("testServerToken2022");
telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
TelemetryEntry telemetryEntry = telemetryServiceSpy.getTelemetry().getEntries().get(0);
assertNotNull(telemetryEntry);
assertEquals(3, telemetryEntry.getFeatures().getExecuteMboxCount());
assertEquals(1, telemetryEntry.getFeatures().getPrefetchViewCount());
assertEquals(true, telemetryEntry.getFeatures().getExecutePageLoad());
assertEquals(true, telemetryEntry.getFeatures().getPrefetchPageLoad());
assertEquals(3, telemetryEntry.getFeatures().getPrefetchMboxCount());
assertEquals("testID", telemetryEntry.getRequestId());
assertEquals("testServerToken2022", telemetryEntry.getTelemetryServerToken());
assertEquals(ExecutionMode.EDGE, telemetryEntry.getMode());
assertEquals(DecisioningMethod.SERVER_SIDE.toString(), telemetryEntry.getFeatures().getDecisioningMethod());
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testExecutionModeForServerSide.
@Test
void testExecutionModeForServerSide() throws NoSuchFieldException {
setup(true, DecisioningMethod.SERVER_SIDE, "testExecutionModeServerSide");
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
deliveryResponse.setEdgeHost("mboxedge35.tt.omtrdc.net");
TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
targetDeliveryResponse.getResponse().setRequestId("testID");
telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
Telemetry telemetry = telemetryServiceSpy.getTelemetry();
assertEquals(ExecutionMode.EDGE, telemetry.getEntries().get(0).getMode());
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testExecutionModeForHybridWithNotAllLocal.
/**
* Test to verify telemetryEntry has correct executionMode For hybrid & status 200 we should have
* mode as local
*
* @throws NoSuchFieldException
*/
@Test
void testExecutionModeForHybridWithNotAllLocal() throws NoSuchFieldException {
setup(true, DecisioningMethod.HYBRID, "testExecutionModeHybridWithNotALlLocal");
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.HYBRID).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
deliveryResponse.setEdgeHost("mboxedge35.tt.omtrdc.net");
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.EDGE, telemetryEntry.getMode());
}
Aggregations