Search in sources :

Example 71 with TargetDeliveryRequest

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

the class OnDeviceDecisioningEvaluatorTest method testRemoteAllViews.

@Test
public void testRemoteAllViews() throws JsonProcessingException, NoSuchFieldException {
    OnDeviceDecisioningRuleSet ruleSet = new OnDeviceDecisioningRuleSet();
    List<String> views = new ArrayList<>();
    views.add("test");
    views.add("test2");
    FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("localViews"), new ArrayList<>());
    FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("remoteViews"), views);
    String serializedRuleSet = objectMapper.writeValueAsString(ruleSet);
    RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoader(serializedRuleSet);
    evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
    TargetDeliveryRequest request = TargetDeliveryRequest.builder().prefetch(new PrefetchRequest().addViewsItem(new ViewRequest())).build();
    OnDeviceDecisioningEvaluation evaluation = evaluator.evaluateLocalExecution(request);
    assertFalse(evaluation.isAllLocal());
    List<String> remoteViews = evaluation.getRemoteViews();
    remoteViews.sort(Comparator.naturalOrder());
    assertEquals(views, remoteViews);
    assertNull(evaluation.getRemoteMBoxes());
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) ArrayList(java.util.ArrayList) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) ViewRequest(com.adobe.target.delivery.v1.model.ViewRequest) OnDeviceDecisioningRuleSet(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet) OnDeviceDecisioningEvaluation(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation) Test(org.junit.jupiter.api.Test)

Example 72 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestOutTimeRange.

@Test
void testTargetDeliveryLocalRequestOutTimeRange() 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(1590516000000L);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "daterange-mbox");
    verifyHTMLContent(prefetchOptions, "<strong>default result</strong>", "wQY/V1IOYec8T4fAT5ww7mqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
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)

Example 73 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestWrongBrowserFirefox.

@Test
void testTargetDeliveryLocalRequestWrongBrowserFirefox() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_BROWSER.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873", DecisioningMethod.HYBRID, "browser-mbox");
    targetDeliveryRequest.getDeliveryRequest().getContext().setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/71.0");
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "browser-mbox");
    verifyHTMLContent(prefetchOptions, "<h1>it's firefox</h1>", "B8C2FP2IuBgmeJcDfXHjGpNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
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 74 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestTimeRange2.

@Test
void testTargetDeliveryLocalRequestTimeRange2() 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(1583348400000L);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "daterange-mbox");
    verifyHTMLContent(prefetchOptions, "<strong>date range 2 (mar 2 - 6)</strong>", "wQY/V1IOYec8T4fAT5ww7pNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
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)

Example 75 with TargetDeliveryRequest

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

the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestPriority.

@Test
void testTargetDeliveryLocalRequestPriority() throws IOException, NoSuchFieldException {
    fileRuleLoader("DECISIONING_PAYLOAD_PRIORITIES.json", localService);
    TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("338e3c1e51f7416a8e1ccba4f81acea0.28_0", DecisioningMethod.HYBRID, "kitty");
    targetDeliveryRequest.getDeliveryRequest().getContext().setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/71.0");
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    assertEquals(1, targetDeliveryResponse.getResponse().getPrefetch().getMboxes().size());
    List<Option> prefetchOptions = extractOptions(targetDeliveryRequest, targetDeliveryResponse, "kitty");
    verifyHTMLContent(prefetchOptions, "<div>kitty high with targeting: Firefox</div>", "/DhjxnVDh9heBZ0MrYFLF2qipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
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