Search in sources :

Example 91 with TargetDeliveryRequest

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==");
}
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 92 with TargetDeliveryRequest

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());
}
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 93 with TargetDeliveryRequest

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);
}
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 94 with TargetDeliveryRequest

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());
}
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 95 with TargetDeliveryRequest

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