Search in sources :

Example 86 with TargetDeliveryRequest

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

the class UserParamsCollatorTest method testSafariIphone.

@Test
public void testSafariIphone() {
    String userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1";
    TargetDeliveryRequest request = requestWithUserAgent(userAgent);
    Map<String, Object> result = collator.collateParams(request, pageLoad);
    assertEquals("iphone", result.get(UserParamsCollator.USER_BROWSER_TYPE));
    assertEquals("13", result.get(UserParamsCollator.USER_BROWSER_VERSION));
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 87 with TargetDeliveryRequest

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

the class UserParamsCollatorTest method testChromeLinux.

@Test
public void testChromeLinux() {
    String userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36";
    TargetDeliveryRequest request = requestWithUserAgent(userAgent);
    Map<String, Object> result = collator.collateParams(request, pageLoad);
    assertEquals("chrome", result.get(UserParamsCollator.USER_BROWSER_TYPE));
    assertEquals("44", result.get(UserParamsCollator.USER_BROWSER_VERSION));
    assertEquals("linux", result.get(UserParamsCollator.USER_PLATFORM));
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 88 with TargetDeliveryRequest

use of com.adobe.target.edge.client.model.TargetDeliveryRequest 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)

Example 89 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestPageload2.

@Test
void testTargetDeliveryLocalRequestPageload2() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_GLOBAL_MBOX.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");
    PrefetchRequest prefetchRequest = new PrefetchRequest();
    RequestDetails preload = new RequestDetails();
    preload.setParameters(new HashMap<String, String>() {

        {
            put("foo", "bar");
        }
    });
    prefetchRequest.setPageLoad(preload);
    targetDeliveryRequest.getDeliveryRequest().setPrefetch(prefetchRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = targetDeliveryResponse.getResponse().getPrefetch().getPageLoad().getOptions();
    assertNotNull(prefetchOptions);
    assertEquals(3, prefetchOptions.size());
    int matches = 0;
    for (Option option : prefetchOptions) {
        assertEquals(OptionType.HTML, option.getType());
        String preContent = (String) option.getContent();
        switch(preContent) {
            case "<div>Chrometastic</div>":
                assertEquals("9FNM3ikASssS+sVoFXNulGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
                matches++;
                break;
            case "<div>foo=bar experience C</div>":
                assertEquals("0L1rCkDps3F+UEAm1B9A4AreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
                matches++;
                break;
            case "<div>lion</div>":
                assertEquals("5C2cbrGD+bQ5qOATNGy1AQreqXMfVUcUx0s/BHR5kCKCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
                matches++;
                break;
            case "<div>whale</div>":
                assertEquals("5C2cbrGD+bQ5qOATNGy1AWqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option.getEventToken());
                matches++;
                break;
            default:
                throw new IllegalStateException("unexpected content");
        }
    }
    assertEquals(3, matches);
}
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 90 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestVisitor2.

@Test
void testTargetDeliveryLocalRequestVisitor2() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_ADDRESS.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("58734fba-262c-4722-b4a3-ac0a93916874", DecisioningMethod.HYBRID, "offer2");
    targetDeliveryRequest.getDeliveryRequest().getContext().setAddress(new Address().url("https://test.com?foo=bar"));
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "offer2");
    Map<String, Object> expectedContent = new HashMap<String, Object>() {

        {
            put("baz", 1);
        }
    };
    verifyJSONContent(prefetchOptions, expectedContent, "mWtD0yDAXMnesyQOa7/jS2qipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
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