Search in sources :

Example 51 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalPageLoadViewABJason.

@Test
void testTargetDeliveryLocalPageLoadViewABJason() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_PAGELOAD_VEC_AB.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 > 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", "/SXLXTYTqMY5xlnwaQZrEWqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setStyle", "HTML > BODY > UL:nth-of-type(1) > LI:nth-of-type(2)", "HTML > BODY > UL:nth-of-type(1) > LI:nth-of-type(2)", new HashMap<String, String>() {

                {
                    put("background-color", "rgba(170,255,255,1)");
                    put("priority", "important");
                }
            }, "/SXLXTYTqMY5xlnwaQZrEWqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("insertBefore", "HTML > BODY > DIV.offer:eq(0) > IMG:nth-of-type(1)", "HTML > BODY > DIV:nth-of-type(2) > IMG:nth-of-type(1)", "<p id=\"action_insert_15887183492726231\">experience A</p>", "/SXLXTYTqMY5xlnwaQZrEWqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("insertAfter", "HTML > BODY > DIV:nth-of-type(1) > H1:nth-of-type(1)", "HTML > BODY > DIV:nth-of-type(1) > H1:nth-of-type(1)", "<p id=\"action_insert_15882850825432970\">Better to remain silent and be thought a fool than to speak out and remove all doubt.</p>", "6Na6eWan1u0HrN32JDT54GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setStyle", "#action_insert_15882850825432970", "#action_insert_15882850825432970", new HashMap<String, String>() {

                {
                    put("background-color", "rgba(255,255,170,1)");
                    put("priority", "important");
                }
            }, "6Na6eWan1u0HrN32JDT54GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    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 52 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalNamedViewsBoth.

@Test
void testTargetDeliveryLocalNamedViewsBoth() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_VIEWS.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", Collections.emptyList(), false);
    Map<String, String> params = new HashMap<String, String>() {

        {
            put("jason", "correct");
            put("greg", "correct");
        }
    };
    targetDeliveryRequest.getDeliveryRequest().getPrefetch().getViews().get(0).setParameters(params);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> contactOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "contact", false);
    List<SelectorContent> contactSelectors = new ArrayList<SelectorContent>() {

        {
            add(new SelectorContent("insertBefore", "#spa-content > P:nth-of-type(1)", "#spa-content > P:nth-of-type(1)", "<div id=\"action_insert_15889714592501888\">Please call Jason immediately</div>", "DKyEy8B6J+arIj6GhXNW/GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            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(255,255,170,1)");
                    put("priority", "important");
                }
            }, "DKyEy8B6J+arIj6GhXNW/GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    verifyContent(contactOptions, contactSelectors);
}
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 53 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalPageLoadViewAB.

@Test
void testTargetDeliveryLocalPageLoadViewAB() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_PAGELOAD_VEC_AB.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916877", null, false);
    Map<String, String> params = new HashMap<String, String>() {
    };
    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("insertBefore", "HTML > BODY > DIV.offer:eq(0) > IMG:nth-of-type(1)", "HTML > BODY > DIV:nth-of-type(2) > IMG:nth-of-type(1)", "<p id=\"action_insert_15887183492726231\">experience A</p>", "/SXLXTYTqMY5xlnwaQZrEWqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("insertAfter", "HTML > BODY > DIV:nth-of-type(1) > H1:nth-of-type(1)", "HTML > BODY > DIV:nth-of-type(1) > H1:nth-of-type(1)", "<p id=\"action_insert_15882850825432970\">Better to remain silent and be thought a fool than to speak out and remove all doubt.</p>", "6Na6eWan1u0HrN32JDT54GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setStyle", "#action_insert_15882850825432970", "#action_insert_15882850825432970", new HashMap<String, String>() {

                {
                    put("background-color", "rgba(255,255,170,1)");
                    put("priority", "important");
                }
            }, "6Na6eWan1u0HrN32JDT54GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    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 54 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse 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 55 with TargetDeliveryResponse

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

the class TargetDeliveryLocalPropertyTest method optionsForProperty.

@SuppressWarnings("unchecked")
private List<Option> optionsForProperty(String propertyToken, boolean noProperty) {
    TargetDeliveryRequestBuilder builder = TargetDeliveryRequest.builder().context(new Context().address(new Address().url("https://test.com"))).prefetch(new PrefetchRequest().addMboxesItem(new MboxRequest().name("superfluous-mbox").index(0))).id(new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916874")).decisioningMethod(DecisioningMethod.HYBRID);
    if (!noProperty) {
        builder.property(new Property().token(propertyToken));
    }
    TargetDeliveryRequest targetDeliveryRequest = builder.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("superfluous-mbox", mboxResponse.getName());
    return mboxResponse.getOptions();
}
Also used : TargetDeliveryRequestBuilder(com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder) 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

TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)66 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)58 Test (org.junit.jupiter.api.Test)53 TimingTool (com.adobe.target.edge.client.utils.TimingTool)13 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)10 Context (com.adobe.target.delivery.v1.model.Context)9 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)9 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)9 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)9 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)9 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)8 Property (com.adobe.target.delivery.v1.model.Property)7 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)6 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)5 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 ParamsCollator (com.adobe.target.edge.client.ondevice.collator.ParamsCollator)4 CustomerState (com.adobe.experiencecloud.ecid.visitor.CustomerState)3 TargetRequestException (com.adobe.target.edge.client.exception.TargetRequestException)3 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)3 ResponseWrapper (com.adobe.target.edge.client.http.ResponseWrapper)3