use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalPageLoadViewXTNone.
@Test
void testTargetDeliveryLocalPageLoadViewXTNone() throws IOException, NoSuchFieldException {
fileRuleLoader("DECISIONING_PAYLOAD_PAGELOAD_VEC_XT.json", localService);
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916877", null, false);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
List<Option> options = extractOptions(targetDeliveryRequest, targetDeliveryResponse, null, false);
List<SelectorContent> selectors = new ArrayList<SelectorContent>() {
{
add(new SelectorContent("setHtml", "HTML > BODY > DIV:nth-of-type(1) > H1:nth-of-type(1)", "HTML > BODY > DIV:nth-of-type(1) > H1:nth-of-type(1)", "Hello everyone", "39UdigzDfmb97ogXP1PN6wreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
add(new SelectorContent("setHtml", "HTML > BODY > UL:nth-of-type(1) > LI:nth-of-type(3)", "HTML > BODY > UL:nth-of-type(1) > LI:nth-of-type(3)", "all visitors", "39UdigzDfmb97ogXP1PN6wreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
}
};
verifyContent(options, selectors);
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testTelemetryNotSentExecute.
/**
* When telemetryEnabled flag is set to false verify we don't store telemetry data
*
* @throws NoSuchFieldException
* @throws IOException
*/
@Test
void testTelemetryNotSentExecute() throws NoSuchFieldException, IOException {
setup(false, DecisioningMethod.ON_DEVICE, "testTelemetryNotSentExecute");
TargetService targetServiceMock = mock(TargetService.class, RETURNS_DEFAULTS);
NotificationService notificationService = new NotificationService(targetServiceMock, clientConfig, clusterLocator);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), notificationService);
fileRuleLoader("DECISIONING_PAYLOAD_ALL_MATCHES.json", localService);
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(new Context().channel(ChannelType.WEB)).execute(new ExecuteRequest().addMboxesItem(new MboxRequest().index(0).name("allmatches"))).prefetch(new PrefetchRequest().addMboxesItem(new MboxRequest().index(0).name("TEST_PREFETCH"))).decisioningMethod(DecisioningMethod.ON_DEVICE).build();
targetJavaClient.getOffers(targetDeliveryRequest);
ArgumentCaptor<TargetDeliveryRequest> captor = ArgumentCaptor.forClass(TargetDeliveryRequest.class);
verify(targetServiceMock, timeout(1000)).executeNotificationAsync(captor.capture());
Telemetry telemetry = captor.getValue().getDeliveryRequest().getTelemetry();
List<Notification> notifications = captor.getValue().getDeliveryRequest().getNotifications();
assertNull(telemetry);
assertEquals(notifications.size(), 1);
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluatorTest method testAllLocalNoRemoteMbox.
@Test
public void testAllLocalNoRemoteMbox() throws JsonProcessingException, NoSuchFieldException {
OnDeviceDecisioningRuleSet ruleSet = new OnDeviceDecisioningRuleSet();
List<String> localMboxes = new ArrayList<>();
localMboxes.add("test");
localMboxes.add("test2");
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("localMboxes"), localMboxes);
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("remoteMboxes"), new ArrayList<String>());
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);
assertTrue(evaluation.isAllLocal());
assertNull(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 testAllLocalNoRemoteAllViews.
@Test
public void testAllLocalNoRemoteAllViews() throws JsonProcessingException, NoSuchFieldException {
OnDeviceDecisioningRuleSet ruleSet = new OnDeviceDecisioningRuleSet();
List<String> localViews = new ArrayList<>();
localViews.add("test");
localViews.add("test2");
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("localViews"), localViews);
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("remoteViews"), new ArrayList<String>());
String serializedRuleSet = objectMapper.writeValueAsString(ruleSet);
RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoader(serializedRuleSet);
evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
TargetDeliveryRequest request = TargetDeliveryRequest.builder().prefetch(new PrefetchRequest().addViewsItem(new ViewRequest())).build();
OnDeviceDecisioningEvaluation evaluation = evaluator.evaluateLocalExecution(request);
assertTrue(evaluation.isAllLocal());
assertNull(evaluation.getRemoteMBoxes());
assertNull(evaluation.getRemoteViews());
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class PageParamsCollatorTest method testCollator.
@Test
public void testCollator() {
VisitorProvider.init("testOrgId");
String url = "http://WWW.TARGET.ADOBE.COM/ABOUT/?foo=bar&name=JimmyG#Part1";
RequestDetails pageLoad = new RequestDetails();
TargetDeliveryRequest request = TargetDeliveryRequest.builder().execute(new ExecuteRequest().pageLoad(pageLoad)).context(new Context().address(new Address().url(url))).build();
PageParamsCollator collator = new PageParamsCollator();
Map<String, Object> result = collator.collateParams(request, pageLoad);
assertEquals(url, result.get(PageParamsCollator.PAGE_URL));
assertEquals(url.toLowerCase(), result.get(PageParamsCollator.PAGE_URL_LOWER));
assertEquals("/ABOUT/", result.get(PageParamsCollator.PAGE_PATH));
assertEquals("/about/", result.get(PageParamsCollator.PAGE_PATH_LOWER));
assertEquals("WWW.TARGET.ADOBE.COM", result.get(PageParamsCollator.PAGE_DOMAIN));
assertEquals("www.target.adobe.com", result.get(PageParamsCollator.PAGE_DOMAIN_LOWER));
assertEquals("TARGET", result.get(PageParamsCollator.PAGE_SUBDOMAIN));
assertEquals("target", result.get(PageParamsCollator.PAGE_SUBDOMAIN_LOWER));
assertEquals("COM", result.get(PageParamsCollator.PAGE_TOP_LEVEL_DOMAIN));
assertEquals("com", result.get(PageParamsCollator.PAGE_TOP_LEVEL_DOMAIN_LOWER));
assertEquals("foo=bar&name=JimmyG", result.get(PageParamsCollator.PAGE_QUERY));
assertEquals("foo=bar&name=jimmyg", result.get(PageParamsCollator.PAGE_QUERY_LOWER));
assertEquals("Part1", result.get(PageParamsCollator.PAGE_FRAGMENT));
assertEquals("part1", result.get(PageParamsCollator.PAGE_FRAGMENT_LOWER));
}
Aggregations