use of com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalViewTest method localDeliveryRequest.
private TargetDeliveryRequest localDeliveryRequest(String visitorIdStr, List<String> views, boolean execute) {
Context context = getLocalContext();
context.setAddress(new Address().url("http://local-target-test/"));
PrefetchRequest prefetchRequest = new PrefetchRequest();
if (views != null) {
if (views.isEmpty()) {
prefetchRequest.addViewsItem(new ViewRequest());
} else {
for (String viewName : views) {
prefetchRequest.addViewsItem(new ViewRequest().name(viewName));
}
}
} else {
prefetchRequest.setPageLoad(new RequestDetails());
}
ExecuteRequest executeRequest = null;
if (execute) {
executeRequest = new ExecuteRequest();
executeRequest.setPageLoad(new RequestDetails());
}
VisitorId visitorId = new VisitorId().tntId(visitorIdStr);
TargetDeliveryRequestBuilder targetDeliveryRequestBuilder = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).id(visitorId).decisioningMethod(DecisioningMethod.ON_DEVICE);
if (execute) {
targetDeliveryRequestBuilder.execute(executeRequest);
}
TargetDeliveryRequest targetDeliveryRequest = targetDeliveryRequestBuilder.build();
assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
return targetDeliveryRequest;
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder in project target-java-sdk by adobe.
the class TargetDeliveryLocalPropertyTest method optionsForProperty.
@SuppressWarnings("unchecked")
private List<Option> optionsForProperty(String propertyToken, boolean noProperty) {
TargetDeliveryRequestBuilder builder = TargetDeliveryRequest.builder().context(new Context().address(new Address().url("https://test.com"))).prefetch(new PrefetchRequest().addMboxesItem(new MboxRequest().name("superfluous-mbox").index(0))).id(new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916874")).decisioningMethod(DecisioningMethod.HYBRID);
if (!noProperty) {
builder.property(new Property().token(propertyToken));
}
TargetDeliveryRequest targetDeliveryRequest = builder.build();
TargetDeliveryResponse response = targetJavaClient.getOffers(targetDeliveryRequest);
assertNotNull(response);
assertEquals(200, response.getStatus());
verify(defaultTargetHttpClient, never()).execute(any(Map.class), any(String.class), eq(targetDeliveryRequest), any(Class.class));
DeliveryResponse deliveryResponse = response.getResponse();
assertNotNull(deliveryResponse);
PrefetchResponse prefetchResponse = deliveryResponse.getPrefetch();
assertNotNull(prefetchResponse);
List<PrefetchMboxResponse> mboxResponses = prefetchResponse.getMboxes();
assertNotNull(mboxResponses);
assertEquals(1, mboxResponses.size());
PrefetchMboxResponse mboxResponse = mboxResponses.get(0);
assertNotNull(mboxResponse);
assertEquals(0, mboxResponse.getIndex());
assertEquals("superfluous-mbox", mboxResponse.getName());
return mboxResponse.getOptions();
}
Aggregations