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