Search in sources :

Example 16 with TargetDeliveryRequest

use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.

the class TargetDeliveryRequestLocalViewTest method localDeliveryRequest.

private TargetDeliveryRequest localDeliveryRequest(String visitorIdStr, List<String> views, boolean execute) {
    Context context = getLocalContext();
    context.setAddress(new Address().url("http://local-target-test/"));
    PrefetchRequest prefetchRequest = new PrefetchRequest();
    if (views != null) {
        if (views.isEmpty()) {
            prefetchRequest.addViewsItem(new ViewRequest());
        } else {
            for (String viewName : views) {
                prefetchRequest.addViewsItem(new ViewRequest().name(viewName));
            }
        }
    } else {
        prefetchRequest.setPageLoad(new RequestDetails());
    }
    ExecuteRequest executeRequest = null;
    if (execute) {
        executeRequest = new ExecuteRequest();
        executeRequest.setPageLoad(new RequestDetails());
    }
    VisitorId visitorId = new VisitorId().tntId(visitorIdStr);
    TargetDeliveryRequestBuilder targetDeliveryRequestBuilder = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).id(visitorId).decisioningMethod(DecisioningMethod.ON_DEVICE);
    if (execute) {
        targetDeliveryRequestBuilder.execute(executeRequest);
    }
    TargetDeliveryRequest targetDeliveryRequest = targetDeliveryRequestBuilder.build();
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    return targetDeliveryRequest;
}
Also used : TargetTestDeliveryRequestUtils.getLocalContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getLocalContext) TargetDeliveryRequestBuilder(com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest)

Example 17 with TargetDeliveryRequest

use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalNamedViews.

@Test
void testTargetDeliveryLocalNamedViews() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_VIEWS.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", Collections.emptyList(), false);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> contactOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "contact", false);
    List<SelectorContent> contactSelectors = new ArrayList<SelectorContent>() {

        {
            add(new SelectorContent("insertAfter", "#spa-content > P:nth-of-type(1)", "#spa-content > P:nth-of-type(1)", "<span id=\"action_insert_15889715194712006\">Please do not contact us.</span>", "DKyEy8B6J+arIj6GhXNW/AreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setStyle", "#spa-content > P:nth-of-type(1)", "#spa-content > P:nth-of-type(1)", new HashMap<String, String>() {

                {
                    put("background-color", "rgba(127,0,0,1)");
                    put("priority", "important");
                }
            }, "DKyEy8B6J+arIj6GhXNW/AreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    verifyContent(contactOptions, contactSelectors);
    List<Option> homeOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "home", false);
    List<SelectorContent> homeSelectors = new ArrayList<SelectorContent>() {

        {
            add(new SelectorContent("insertAfter", "#spa-content > P:nth-of-type(1)", "#spa-content > P:nth-of-type(1)", "<p id=\"action_insert_15889689998702412\">experience A</p>", "ob3/yMzSVllQx2v2P7122GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setHtml", "#spa-content > H3:nth-of-type(1)", "#spa-content > H3:nth-of-type(1)", "nobody home - exp A", "ob3/yMzSVllQx2v2P7122GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setHtml", "#spa-content > H3:nth-of-type(1)", "#spa-content > H3:nth-of-type(1)", "Home - Experience A", "XQ6HqnRfrxl3ausAjtQJj2qipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setHtml", "#spa-content > P:nth-of-type(1)", "#spa-content > P:nth-of-type(1)", "experience A! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut rhoncus, magna et dignissim ullamcorper, magna ipsum pharetra velit, vel egestas magna leo interdum urna. Etiam purus massa, accumsan in elit sit amet, posuere maximus augue. Donec non velit sit amet ipsum feugiat aliquet id in metus. Integer a auctor nisl. Donec ac lacinia eros. Proin nisl magna, bibendum ut tellus vitae, mattis laoreet lacus. Pellentesque mauris lorem, scelerisque quis nisi ac, vulputate tincidunt est. Maecenas ex justo, ultrices non neque sed, fermentum maximus diam. Vestibulum at facilisis magna. Ut eu tristique lectus. Proin gravida leo eu fermentum ullamcorper. Suspendisse gravida nibh vitae ultricies ultricies. Donec fermentum, metus id tincidunt dapibus, tellus lacus tristique felis, non posuere nibh ligula sed est.", "XQ6HqnRfrxl3ausAjtQJj2qipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    verifyContent(homeOptions, homeSelectors);
}
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 18 with TargetDeliveryRequest

use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalMacros.

@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryLocalMacros() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_CAMPAIGN_MACROS.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", Collections.emptyList(), false);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> pageLoadOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "contact", // targetDeliveryResponse.getResponse().getPrefetch().getPageLoad().getOptions();
    false);
    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<>(Collections.singletonList("<div id=\"action_insert_1599086396006761\">campaign macros view</div>")), 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 19 with TargetDeliveryRequest

use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalPageLoadViewXTJason.

@Test
void testTargetDeliveryLocalPageLoadViewXTJason() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_PAGELOAD_VEC_XT.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916877", null, false);
    Map<String, String> params = new HashMap<String, String>() {

        {
            put("jason", "correct");
        }
    };
    targetDeliveryRequest.getDeliveryRequest().getPrefetch().getPageLoad().setParameters(params);
    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 jason", "39UdigzDfmb97ogXP1PN65NWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setHtml", "HTML > BODY > UL:nth-of-type(1) > LI:nth-of-type(2)", "HTML > BODY > UL:nth-of-type(1) > LI:nth-of-type(2)", "jason is correct", "39UdigzDfmb97ogXP1PN65NWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    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 20 with TargetDeliveryRequest

use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.

the class TargetDeliveryLocalGeoTest method optionsForGeo.

@SuppressWarnings("unchecked")
private List<Option> optionsForGeo(Geo geo) {
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(new Context().geo(geo).address(new Address().url("https://test.com"))).prefetch(new PrefetchRequest().addMboxesItem(new MboxRequest().name("geo").index(0))).id(new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916874")).decisioningMethod(DecisioningMethod.HYBRID).build();
    TargetDeliveryResponse response = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNotNull(response);
    assertEquals(200, response.getStatus());
    verify(defaultTargetHttpClient, never()).execute(any(Map.class), any(String.class), eq(targetDeliveryRequest), any(Class.class));
    DeliveryResponse deliveryResponse = response.getResponse();
    assertNotNull(deliveryResponse);
    PrefetchResponse prefetchResponse = deliveryResponse.getPrefetch();
    assertNotNull(prefetchResponse);
    List<PrefetchMboxResponse> mboxResponses = prefetchResponse.getMboxes();
    assertNotNull(mboxResponses);
    assertEquals(1, mboxResponses.size());
    PrefetchMboxResponse mboxResponse = mboxResponses.get(0);
    assertNotNull(mboxResponse);
    assertEquals(0, mboxResponse.getIndex());
    assertEquals("geo", mboxResponse.getName());
    return mboxResponse.getOptions();
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Map(java.util.Map)

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