use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestPageload2.
@Test
void testTargetDeliveryLocalRequestPageload2() 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_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36");
PrefetchRequest prefetchRequest = new PrefetchRequest();
RequestDetails preload = new RequestDetails();
preload.setParameters(new HashMap<String, String>() {
{
put("foo", "bar");
}
});
prefetchRequest.setPageLoad(preload);
targetDeliveryRequest.getDeliveryRequest().setPrefetch(prefetchRequest);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = targetDeliveryResponse.getResponse().getPrefetch().getPageLoad().getOptions();
assertNotNull(prefetchOptions);
assertEquals(3, prefetchOptions.size());
int matches = 0;
for (Option option : prefetchOptions) {
assertEquals(OptionType.HTML, option.getType());
String preContent = (String) option.getContent();
switch(preContent) {
case "<div>Chrometastic</div>":
assertEquals("9FNM3ikASssS+sVoFXNulGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
matches++;
break;
case "<div>foo=bar experience C</div>":
assertEquals("0L1rCkDps3F+UEAm1B9A4AreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", 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(3, matches);
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestVisitor2.
@Test
void testTargetDeliveryLocalRequestVisitor2() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_ADDRESS.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("58734fba-262c-4722-b4a3-ac0a93916874", DecisioningMethod.HYBRID, "offer2");
targetDeliveryRequest.getDeliveryRequest().getContext().setAddress(new Address().url("https://test.com?foo=bar"));
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "offer2");
Map<String, Object> expectedContent = new HashMap<String, Object>() {
{
put("baz", 1);
}
};
verifyJSONContent(prefetchOptions, expectedContent, "mWtD0yDAXMnesyQOa7/jS2qipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestPriority2.
@Test
void testTargetDeliveryLocalRequestPriority2() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_PRIORITIES.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("238e3c1e51f7416a8e1ccba4f81acea0.28_0", DecisioningMethod.HYBRID, "kitty");
targetDeliveryRequest.getDeliveryRequest().getContext().setUserAgent("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
assertEquals(1, targetDeliveryResponse.getResponse().getPrefetch().getMboxes().size());
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "kitty");
verifyHTMLContent(prefetchOptions, "<div>kitty high B</div>", "ruhwp7VESR7F74TJL2DV5ZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestParamsMismatch.
@Test
void testTargetDeliveryLocalRequestParamsMismatch() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_PARAMS.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("338e3c1e51f7416a8e1ccba4f81acea0.28_0", DecisioningMethod.HYBRID, "redundant-mbox");
targetDeliveryRequest.getDeliveryRequest().getPrefetch().getMboxes().get(0).setParameters(new HashMap<String, String>() {
{
put("foo", "bart");
}
});
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "redundant-mbox");
assertNotNull(prefetchOptions);
assertEquals(0, prefetchOptions.size());
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestPageloadMacros.
@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryLocalRequestPageloadMacros() 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();
RequestDetails pageLoad = new RequestDetails();
pageLoad.setParameters(new HashMap<String, String>() {
{
put("user", "Mickey Mouse");
put("pgname", "blippi");
put("browserWidth", "1024");
}
});
prefetchRequest.setPageLoad(pageLoad);
targetDeliveryRequest.getDeliveryRequest().setPrefetch(prefetchRequest);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> pageLoadOptions = targetDeliveryResponse.getResponse().getPrefetch().getPageLoad().getOptions();
assertNotNull(pageLoadOptions);
ArrayList<String> actionContents = new ArrayList<>();
for (Option option : pageLoadOptions) {
for (Map<String, String> action : (List<Map<String, String>>) option.getContent()) {
actionContents.add(action.get("content"));
}
}
Collections.sort(actionContents);
assertEquals(new ArrayList<>(Arrays.asList("362225", "Hello Mickey Mouse", "macros pageLoad", "target-global-mbox")), actionContents);
}
Aggregations