use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestFriday.
@Test
void testTargetDeliveryLocalRequestFriday() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_TIMEFRAME.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873", DecisioningMethod.HYBRID, "daterange-mbox");
ParamsCollator specificTimeCollator = TargetTestDeliveryRequestUtils.getSpecificTimeCollator(1583521200000L);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "daterange-mbox");
verifyHTMLContent(prefetchOptions, "<strong>it's friday</strong>", "wQY/V1IOYec8T4fAT5ww7hB3JWElmEno9qwHyGr0QvSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestMboxMacrosMissingValues.
@Test
void testTargetDeliveryLocalRequestMboxMacrosMissingValues() 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<MboxRequest>() {
{
add((MboxRequest) new MboxRequest().name("macros").index(1).parameters(new HashMap<String, String>() {
{
put("user", "Donald");
}
}));
}
};
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>Donald</li>\n" + " <li>${mbox.pgname}</li>\n" + " <li>${mbox.browserWidth}</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 testTargetDeliveryLocalRequestWrongURL.
@Test
void testTargetDeliveryLocalRequestWrongURL() 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=baz"));
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "offer2");
assertEquals(0, prefetchOptions.size());
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestParams.
@Test
void testTargetDeliveryLocalRequestParams() 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", "bar");
}
});
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "redundant-mbox");
Map<String, Object> expectedContent = new HashMap<String, Object>() {
{
put("foo", "bar");
put("isFooBar", true);
put("experience", "A");
}
};
verifyJSONContent(prefetchOptions, expectedContent, "Zhwxeqy1O2r9Ske1YDA9bGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.
the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithDefaultProperty.
@Test
void testTargetDeliveryRequestWithDefaultProperty() throws NoSuchFieldException {
setup(true);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).build();
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
DeliveryRequest finalRequest = targetDeliveryResponse.getRequest();
assertEquals(TEST_PROPERTY_TOKEN, finalRequest.getProperty().getToken());
}
Aggregations