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));
}
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));
}
Aggregations