use of com.adobe.target.edge.client.model.TargetDeliveryRequest 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.TargetDeliveryRequest 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.TargetDeliveryRequest 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.TargetDeliveryRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluatorTest method testUnknownMbox.
@Test
public void testUnknownMbox() throws JsonProcessingException, NoSuchFieldException {
OnDeviceDecisioningRuleSet ruleSet = new OnDeviceDecisioningRuleSet();
List<String> mboxes = new ArrayList<>();
mboxes.add("test");
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("localMboxes"), mboxes);
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("remoteMboxes"), new ArrayList<>());
String serializedRuleSet = objectMapper.writeValueAsString(ruleSet);
RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoader(serializedRuleSet);
evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
TargetDeliveryRequest request = TargetDeliveryRequest.builder().execute(new ExecuteRequest().addMboxesItem(new MboxRequest().name("test")).addMboxesItem(new MboxRequest().name("test2"))).build();
OnDeviceDecisioningEvaluation evaluation = evaluator.evaluateLocalExecution(request);
assertFalse(evaluation.isAllLocal());
List<String> remoteMboxes = new ArrayList<>();
remoteMboxes.add("test2");
assertEquals(remoteMboxes, evaluation.getRemoteMBoxes());
assertNull(evaluation.getRemoteViews());
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluatorTest method testNoRuleSet.
@Test
public void testNoRuleSet() {
RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoader(null);
evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
TargetDeliveryRequest request = TargetDeliveryRequest.builder().build();
OnDeviceDecisioningEvaluation evaluation = evaluator.evaluateLocalExecution(request);
assertFalse(evaluation.isAllLocal());
assertNull(evaluation.getRemoteMBoxes());
assertNull(evaluation.getRemoteViews());
}
Aggregations