use of com.adobe.target.edge.client.model.TargetDeliveryRequest 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.TargetDeliveryRequest 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.TargetDeliveryRequest 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);
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest 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.TargetDeliveryRequest 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));
}
Aggregations