use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestMboxMacros.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
void testTargetDeliveryLocalRequestMboxMacros() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_CAMPAIGN_MACROS.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_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36");
targetDeliveryRequest.getDeliveryRequest().getContext().setChannel(ChannelType.WEB);
targetDeliveryRequest.getDeliveryRequest().getContext().setAddress(new Address().url("http://local-target-test/"));
targetDeliveryRequest.getDeliveryRequest().getContext().setBrowser(new Browser().host("local-target-test"));
PrefetchRequest prefetchRequest = new PrefetchRequest();
List<MboxRequest> mboxRequests = new ArrayList() {
{
add(new MboxRequest().name("macros").index(1).parameters(new HashMap<String, String>() {
{
put("user", "Mickey Mouse");
put("pgname", "blippi");
put("browserWidth", "1024");
}
}));
}
};
prefetchRequest.setMboxes(mboxRequests);
targetDeliveryRequest.getDeliveryRequest().setPrefetch(prefetchRequest);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
PrefetchMboxResponse mbox = targetDeliveryResponse.getResponse().getPrefetch().getMboxes().get(0);
assertEquals("macros", mbox.getName());
Option option = mbox.getOptions().get(0);
assertEquals(OptionType.HTML, option.getType());
assertEquals("<ol>\n" + " <li>667870</li>\n" + " <li>/campaign_macros/experiences/1/pages/0/zones/0/1599065324776</li>\n" + " <li>362147</li>\n" + " <li>campaign macros</li>\n" + " <li>1</li>\n" + " <li>Experience B</li>\n" + " <li>362147</li>\n" + " <li>campaign macros</li>\n" + " <li>1</li>\n" + " <li>Experience B</li>\n" + " <li>macros</li>\n" + " <li>Mickey Mouse</li>\n" + " <li>blippi</li>\n" + " <li>1024</li>\n" + "</ol>", option.getContent());
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryAttributesHybridRemote.
@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryAttributesHybridRemote() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_RECOMMENDATIONS.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", DecisioningMethod.HYBRID, "daterange-mbox");
targetDeliveryRequest.getDeliveryRequest().getPrefetch().addMboxesItem(new MboxRequest().index(2).name("recommendations"));
TargetDeliveryResponse response = targetJavaClient.getOffers(targetDeliveryRequest);
assertNotNull(response);
assertEquals(200, response.getStatus());
verify(defaultTargetHttpClient, atMostOnce()).execute(any(Map.class), any(String.class), eq(targetDeliveryRequest), any(Class.class));
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse 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.TargetDeliveryResponse 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.TargetDeliveryResponse in project target-java-sdk by adobe.
the class DefaultTargetService method executeRequest.
@Override
public TargetDeliveryResponse executeRequest(TargetDeliveryRequest deliveryRequest) {
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
TargetDeliveryResponse targetDeliveryResponse;
Telemetry telemetry = telemetryService.getTelemetry();
if (!telemetry.getEntries().isEmpty()) {
deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
}
ResponseWrapper<DeliveryResponse> response = callDeliveryApi(deliveryRequest);
targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
/* capture Telemetry information once original request's response is received */
telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
return targetDeliveryResponse;
}
Aggregations