Search in sources :

Example 11 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestAllMatchesNotOverriden.

@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryLocalRequestAllMatchesNotOverriden() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_ALL_MATCHES.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", DecisioningMethod.ON_DEVICE, "allmatches");
    PrefetchRequest prefetchRequest = targetDeliveryRequest.getDeliveryRequest().getPrefetch();
    MboxRequest mboxRequest = prefetchRequest.getMboxes().get(0);
    mboxRequest.setParameters(new HashMap<String, String>() {

        {
            put("foo", "bar");
        }
    });
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "allmatches");
    assertEquals(1, prefetchOptions.size());
    Option option1 = prefetchOptions.get(0);
    assertEquals(OptionType.JSON, option1.getType());
    Map<String, Object> preContent1 = (Map<String, Object>) option1.getContent();
    assertEquals(2, preContent1.get("allmatches"));
    assertEquals("b", preContent1.get("allmatches2_exp"));
    assertEquals("aNT5qgpj/qd5U7cLpV7p05NWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option1.getEventToken());
}
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 12 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalMboxTest method extractOptions.

@SuppressWarnings("unchecked")
private List<Option> extractOptions(TargetDeliveryRequest targetDeliveryRequest, TargetDeliveryResponse targetDeliveryResponse, String prefetchMbox) {
    DeliveryResponse response = targetDeliveryResponse.getResponse();
    assertNotNull(response);
    PrefetchResponse preResponse = response.getPrefetch();
    assertNotNull(preResponse);
    List<PrefetchMboxResponse> preMboxes = preResponse.getMboxes();
    assertNotNull(preMboxes);
    List<Option> prefetchOptions = null;
    if (prefetchMbox != null) {
        assertEquals(1, preMboxes.size());
        PrefetchMboxResponse preMboxResponse = preMboxes.get(0);
        assertEquals(prefetchMbox, preMboxResponse.getName());
        assertEquals(1, preMboxResponse.getIndex());
        prefetchOptions = preMboxResponse.getOptions();
    } else {
        assertEquals(0, preMboxes.size());
    }
    ExecuteResponse execResponse = response.getExecute();
    assertNotNull(execResponse);
    List<MboxResponse> mboxes = execResponse.getMboxes();
    assertNotNull(mboxes);
    verify(defaultTargetHttpClient, never()).execute(any(Map.class), any(String.class), eq(targetDeliveryRequest), any(Class.class));
    verify(defaultTargetHttpClient, atMostOnce()).execute(any(Map.class), any(String.class), any(TargetDeliveryRequest.class), any(Class.class));
    return prefetchOptions;
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest)

Example 13 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestBrowserChrome.

@Test
void testTargetDeliveryLocalRequestBrowserChrome() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_BROWSER.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873", DecisioningMethod.HYBRID, "browser-mbox");
    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.87 Safari/537.36");
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "browser-mbox");
    verifyHTMLContent(prefetchOptions, "<h1>it's chrome</h1>", "B8C2FP2IuBgmeJcDfXHjGpZBXFCzaoRRABbzIA9EnZOCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
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 14 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalPageLoadViewXTExecute.

@Test
void testTargetDeliveryLocalPageLoadViewXTExecute() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_PAGELOAD_VEC_XT.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916877", null, true);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> options = extractOptions(targetDeliveryRequest, targetDeliveryResponse, null, true);
    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", null));
            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", null));
        }
    };
    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 15 with TargetDeliveryResponse

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

the class TargetDeliveryRequestLocalViewTest method testTargetDeliveryLocalNamedViewsGreg.

@Test
void testTargetDeliveryLocalNamedViewsGreg() 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("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)", "<span id=\"action_insert_15889714897491922\">Please email Greg immediately</span>", "DKyEy8B6J+arIj6GhXNW/JNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            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(170,255,255,1)");
                    put("priority", "important");
                }
            }, "DKyEy8B6J+arIj6GhXNW/JNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
        }
    };
    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_15889690455422475\">greg = correct</p>", "ob3/yMzSVllQx2v2P7122GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            add(new SelectorContent("setHtml", "#spa-content > H3:nth-of-type(1)", "#spa-content > H3:nth-of-type(1)", "greg home - exp A", "ob3/yMzSVllQx2v2P7122GqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
            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)

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