use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method localDeliveryRequest.
private TargetDeliveryRequest localDeliveryRequest(String visitorIdStr, DecisioningMethod mode, String prefetchMbox) {
Context context = getLocalContext();
PrefetchRequest prefetchRequest = null;
if (prefetchMbox != null) {
prefetchRequest = getMboxPrefetchLocalRequest(prefetchMbox);
}
VisitorId visitorId = new VisitorId().tntId(visitorIdStr);
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).id(visitorId).decisioningMethod(mode).build();
assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
return targetDeliveryRequest;
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestBrowserNoMatch.
@Test
void testTargetDeliveryLocalRequestBrowserNoMatch() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_BROWSER.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873", DecisioningMethod.HYBRID, "browser-mbox");
targetDeliveryRequest.getDeliveryRequest().getContext().setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134");
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "browser-mbox");
verifyHTMLContent(prefetchOptions, "<h1>not firefox, safari or chrome</h1>", "B8C2FP2IuBgmeJcDfXHjGmqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestPageload.
@Test
void testTargetDeliveryLocalRequestPageload() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_GLOBAL_MBOX.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", DecisioningMethod.ON_DEVICE, null);
targetDeliveryRequest.getDeliveryRequest().getContext().setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/71.0");
PrefetchRequest prefetchRequest = new PrefetchRequest();
prefetchRequest.setPageLoad(new RequestDetails());
targetDeliveryRequest.getDeliveryRequest().setPrefetch(prefetchRequest);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = targetDeliveryResponse.getResponse().getPrefetch().getPageLoad().getOptions();
assertNotNull(prefetchOptions);
assertEquals(2, prefetchOptions.size());
int matches = 0;
for (Option option : prefetchOptions) {
assertEquals(OptionType.HTML, option.getType());
String preContent = (String) option.getContent();
switch(preContent) {
case "<div>Firetime</div>":
assertEquals("9FNM3ikASssS+sVoFXNulJNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
matches++;
break;
case "<div>lion</div>":
assertEquals("5C2cbrGD+bQ5qOATNGy1AQreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
matches++;
break;
case "<div>whale</div>":
assertEquals("5C2cbrGD+bQ5qOATNGy1AWqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
matches++;
break;
default:
throw new IllegalStateException("unexpected content");
}
}
assertEquals(2, matches);
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class ClusterLocator method executeRequest.
private void executeRequest(final TargetService targetService) {
TargetDeliveryRequest request = TargetDeliveryRequest.builder().context(new Context().channel(ChannelType.WEB)).build();
future = targetService.executeRequestAsync(request);
future.thenAcceptAsync(response -> {
if (!this.running) {
return;
}
if (response != null && response.getStatus() == SC_OK && response.getResponse() != null && response.getResponse().getId() != null && response.getResponse().getId().getTntId() != null) {
String tntId = response.getResponse().getId().getTntId();
this.locationHint = CookieUtils.locationHintFromTntId(tntId);
} else if (retries++ < MAX_RETRIES) {
this.timer.schedule(new TimerTask() {
@Override
public void run() {
executeRequest(targetService);
}
}, retries * 10000);
}
});
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method localDeliveryRequest.
private TargetDeliveryRequest localDeliveryRequest(String visitorIdStr) {
Context context = getLocalContext();
PrefetchRequest prefetchRequest = getMboxPrefetchLocalRequest("testoffer");
ExecuteRequest executeRequest = getMboxExecuteLocalRequest("testoffer2");
VisitorId visitorId = new VisitorId().tntId(visitorIdStr);
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).id(visitorId).decisioningMethod(DecisioningMethod.HYBRID).build();
assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
return targetDeliveryRequest;
}
Aggregations