Search in sources :

Example 81 with TargetDeliveryRequest

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);
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 82 with TargetDeliveryRequest

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);
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) MboxRequest(com.adobe.target.delivery.v1.model.MboxRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Telemetry(com.adobe.target.delivery.v1.model.Telemetry) Notification(com.adobe.target.delivery.v1.model.Notification) Test(org.junit.jupiter.api.Test)

Example 83 with TargetDeliveryRequest

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());
}
Also used : ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) MboxRequest(com.adobe.target.delivery.v1.model.MboxRequest) ArrayList(java.util.ArrayList) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) OnDeviceDecisioningRuleSet(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet) OnDeviceDecisioningEvaluation(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation) Test(org.junit.jupiter.api.Test)

Example 84 with TargetDeliveryRequest

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());
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) ArrayList(java.util.ArrayList) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) ViewRequest(com.adobe.target.delivery.v1.model.ViewRequest) OnDeviceDecisioningRuleSet(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet) OnDeviceDecisioningEvaluation(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation) Test(org.junit.jupiter.api.Test)

Example 85 with TargetDeliveryRequest

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));
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) Address(com.adobe.target.delivery.v1.model.Address) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) RequestDetails(com.adobe.target.delivery.v1.model.RequestDetails) Test(org.junit.jupiter.api.Test)

Aggregations

TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)104 Test (org.junit.jupiter.api.Test)89 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)62 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)24 Context (com.adobe.target.delivery.v1.model.Context)21 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)20 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)17 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)15 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)13 TimingTool (com.adobe.target.edge.client.utils.TimingTool)13 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)11 DeliveryRequest (com.adobe.target.delivery.v1.model.DeliveryRequest)10 MboxRequest (com.adobe.target.delivery.v1.model.MboxRequest)10 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 Property (com.adobe.target.delivery.v1.model.Property)9 OnDeviceDecisioningEvaluation (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation)9 OnDeviceDecisioningRuleSet (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet)9 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)6 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)6