Search in sources :

Example 21 with TargetDeliveryRequest

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

the class TargetDeliveryLocalGeoTest method testTargetDeliveryLocalRequestGeoNoIPLookup.

@Test
void testTargetDeliveryLocalRequestGeoNoIPLookup() throws IOException, NoSuchFieldException {
    fileRuleLoader(GEO_TEST_FAKE_FILE, localService);
    String ip = "127.0.0.1";
    Geo ipGeo = new Geo().ipAddress(ip);
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(new Context().geo(ipGeo).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.ON_DEVICE).build();
    TargetDeliveryResponse response = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNotNull(response);
    assertEquals(200, response.getStatus());
    verify(mockGeoClient, atMostOnce()).start(any());
    verify(mockGeoClient, never()).lookupGeo(eq(ip));
}
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 22 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestAddressMbox.

@Test
void testTargetDeliveryLocalRequestAddressMbox() 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"));
    targetDeliveryRequest.getDeliveryRequest().getPrefetch().getMboxes().get(0).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)

Example 23 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestAllMatches.

@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryLocalRequestAllMatches() throws IOException, NoSuchFieldException {
    String mbox = "allmatches";
    Set<String> onDeviceAllMatchingRulesMboxes = new HashSet<String>() {

        {
            add(mbox);
        }
    };
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("onDeviceAllMatchingRulesMboxes"), onDeviceAllMatchingRulesMboxes);
    fileRuleLoader("DECISIONING_PAYLOAD_ALL_MATCHES.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874", DecisioningMethod.ON_DEVICE, mbox);
    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);
    DeliveryResponse response = targetDeliveryResponse.getResponse();
    assertNotNull(response);
    PrefetchResponse preResponse = response.getPrefetch();
    assertNotNull(preResponse);
    List<PrefetchMboxResponse> preMboxes = preResponse.getMboxes();
    assertNotNull(preMboxes);
    assertEquals(2, preMboxes.size());
    PrefetchMboxResponse preMboxResponse1 = preMboxes.get(0);
    List<Option> prefetchOptions1 = preMboxResponse1.getOptions();
    assertEquals(1, prefetchOptions1.size());
    Option option1 = prefetchOptions1.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());
    PrefetchMboxResponse preMboxResponse2 = preMboxes.get(1);
    List<Option> prefetchOptions2 = preMboxResponse2.getOptions();
    assertEquals(1, prefetchOptions2.size());
    Option option2 = prefetchOptions2.get(0);
    assertEquals(OptionType.JSON, option2.getType());
    Map<String, Object> preContent2 = (Map<String, Object>) option2.getContent();
    assertEquals(1, preContent2.get("allmatches"));
    assertEquals("a", preContent2.get("allmatches1_exp"));
    assertEquals("+hItquQ2BQan0pYxdJmMcGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==", option2.getEventToken());
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 24 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestVisitor1.

@Test
void testTargetDeliveryLocalRequestVisitor1() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_ADDRESS.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-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", 2);
        }
    };
    verifyJSONContent(prefetchOptions, expectedContent, "mWtD0yDAXMnesyQOa7/jS5NWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
    Option option = prefetchOptions.get(0);
    Map<String, Object> responseTokens = option.getResponseTokens();
    assertEquals(333312, responseTokens.get("activity.id"));
    assertEquals("Form Based Activity - offer2 - Feb 19 2020, 10:34", responseTokens.get("activity.name"));
    assertEquals(1, responseTokens.get("experience.id"));
    assertEquals("Experience B", responseTokens.get("experience.name"));
    assertEquals(630814, responseTokens.get("offer.id"));
    assertEquals(3, responseTokens.get("option.id"));
    assertEquals("Offer3", responseTokens.get("option.name"));
    assertEquals("on-device", responseTokens.get("activity.decisioningMethod"));
}
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 25 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestFriday.

@Test
void testTargetDeliveryLocalRequestFriday() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_TIMEFRAME.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873", DecisioningMethod.HYBRID, "daterange-mbox");
    ParamsCollator specificTimeCollator = TargetTestDeliveryRequestUtils.getSpecificTimeCollator(1583521200000L);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "daterange-mbox");
    verifyHTMLContent(prefetchOptions, "<strong>it's friday</strong>", "wQY/V1IOYec8T4fAT5ww7hB3JWElmEno9qwHyGr0QvSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
Also used : ParamsCollator(com.adobe.target.edge.client.ondevice.collator.ParamsCollator) 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