Search in sources :

Example 6 with RequestDetails

use of com.adobe.target.delivery.v1.model.RequestDetails in project target-java-sdk by adobe.

the class TimeParamsCollatorTest method testCollator.

@Test
public void testCollator() {
    VisitorProvider.init("testOrgId");
    TimeParamsCollator collator = mock(TimeParamsCollator.class, CALLS_REAL_METHODS);
    long now = 1592433971000L;
    Mockito.doReturn(now).when(collator).currentTimestamp();
    RequestDetails pageLoad = new RequestDetails();
    TargetDeliveryRequest request = TargetDeliveryRequest.builder().execute(new ExecuteRequest().pageLoad(pageLoad)).build();
    Map<String, Object> result = collator.collateParams(request, pageLoad);
    assertEquals(now, result.get(TimeParamsCollator.CURRENT_TIMESTAMP));
    assertEquals("3", result.get(TimeParamsCollator.CURRENT_DAY));
    assertEquals("2246", result.get(TimeParamsCollator.CURRENT_TIME));
}
Also used : ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) RequestDetails(com.adobe.target.delivery.v1.model.RequestDetails) Test(org.junit.jupiter.api.Test)

Example 7 with RequestDetails

use of com.adobe.target.delivery.v1.model.RequestDetails in project target-java-sdk by adobe.

the class PageParamsCollatorTest method testCollator.

@Test
public void testCollator() {
    VisitorProvider.init("testOrgId");
    String url = "http://WWW.TARGET.ADOBE.COM/ABOUT/?foo=bar&name=JimmyG#Part1";
    RequestDetails pageLoad = new RequestDetails();
    TargetDeliveryRequest request = TargetDeliveryRequest.builder().execute(new ExecuteRequest().pageLoad(pageLoad)).context(new Context().address(new Address().url(url))).build();
    PageParamsCollator collator = new PageParamsCollator();
    Map<String, Object> result = collator.collateParams(request, pageLoad);
    assertEquals(url, result.get(PageParamsCollator.PAGE_URL));
    assertEquals(url.toLowerCase(), result.get(PageParamsCollator.PAGE_URL_LOWER));
    assertEquals("/ABOUT/", result.get(PageParamsCollator.PAGE_PATH));
    assertEquals("/about/", result.get(PageParamsCollator.PAGE_PATH_LOWER));
    assertEquals("WWW.TARGET.ADOBE.COM", result.get(PageParamsCollator.PAGE_DOMAIN));
    assertEquals("www.target.adobe.com", result.get(PageParamsCollator.PAGE_DOMAIN_LOWER));
    assertEquals("TARGET", result.get(PageParamsCollator.PAGE_SUBDOMAIN));
    assertEquals("target", result.get(PageParamsCollator.PAGE_SUBDOMAIN_LOWER));
    assertEquals("COM", result.get(PageParamsCollator.PAGE_TOP_LEVEL_DOMAIN));
    assertEquals("com", result.get(PageParamsCollator.PAGE_TOP_LEVEL_DOMAIN_LOWER));
    assertEquals("foo=bar&name=JimmyG", result.get(PageParamsCollator.PAGE_QUERY));
    assertEquals("foo=bar&name=jimmyg", result.get(PageParamsCollator.PAGE_QUERY_LOWER));
    assertEquals("Part1", result.get(PageParamsCollator.PAGE_FRAGMENT));
    assertEquals("part1", result.get(PageParamsCollator.PAGE_FRAGMENT_LOWER));
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) Address(com.adobe.target.delivery.v1.model.Address) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) RequestDetails(com.adobe.target.delivery.v1.model.RequestDetails) Test(org.junit.jupiter.api.Test)

Aggregations

RequestDetails (com.adobe.target.delivery.v1.model.RequestDetails)6 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)5 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)4 Test (org.junit.jupiter.api.Test)4 Context (com.adobe.target.delivery.v1.model.Context)3 Geo (com.adobe.target.delivery.v1.model.Geo)2 HashMap (java.util.HashMap)2 Address (com.adobe.target.delivery.v1.model.Address)1 DeliveryRequest (com.adobe.target.delivery.v1.model.DeliveryRequest)1 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)1 Notification (com.adobe.target.delivery.v1.model.Notification)1 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)1 OnDeviceDecisioningRuleSet (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet)1 TimingTool (com.adobe.target.edge.client.utils.TimingTool)1