use of com.adobe.target.edge.client.ondevice.collator.ParamsCollator in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method init.
@BeforeEach
@SuppressWarnings("unchecked")
void init() throws IOException, NoSuchFieldException {
Mockito.lenient().doReturn(CompletableFuture.completedFuture(getTestDeliveryResponse())).when(defaultTargetHttpClient).executeAsync(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
ClientConfig clientConfig = ClientConfig.builder().client("emeaprod4").organizationId(TEST_ORG_ID).build();
VisitorProvider.init(TEST_ORG_ID);
TelemetryService telemetryService = new TelemetryService(clientConfig);
DefaultTargetService targetService = new DefaultTargetService(clientConfig, telemetryService);
localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryService);
targetJavaClient = TargetClient.create(clientConfig);
FieldSetter.setField(targetService, targetService.getClass().getDeclaredField("targetHttpClient"), defaultTargetHttpClient);
FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("targetService"), targetService);
FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("localService"), localService);
RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoaderFromFile("DECISIONING_PAYLOAD_ATTRIBUTES.json");
OnDeviceDecisioningEvaluator evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("ruleLoader"), testRuleLoader);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("onDeviceDecisioningEvaluator"), evaluator);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), mock(NotificationService.class));
FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
ObjectMapper mapper = new JacksonObjectMapper().getMapper();
OnDeviceDecisioningDetailsExecutor decisionHandler = new OnDeviceDecisioningDetailsExecutor(clientConfig, mapper);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("decisionHandler"), decisionHandler);
ParamsCollator specificTimeCollator = TargetTestDeliveryRequestUtils.getSpecificTimeCollator(1582818503000L);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
}
use of com.adobe.target.edge.client.ondevice.collator.ParamsCollator in project target-java-sdk by adobe.
the class TargetDeliveryRequestLocalMboxTest method testTargetDeliveryLocalRequestTimeRange.
@Test
void testTargetDeliveryLocalRequestTimeRange() 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(1582830000000L);
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 1 (feb 27-29)</strong>", "wQY/V1IOYec8T4fAT5ww7unJlneZxJu5VqGhXCosHhWCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==");
}
use of com.adobe.target.edge.client.ondevice.collator.ParamsCollator 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==");
}
use of com.adobe.target.edge.client.ondevice.collator.ParamsCollator 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==");
}
use of com.adobe.target.edge.client.ondevice.collator.ParamsCollator 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==");
}
Aggregations