use of com.adobe.target.delivery.v1.model.PrefetchRequest 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());
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testTelemetryNotSentExecute.
/**
* When telemetryEnabled flag is set to false verify we don't store telemetry data
*
* @throws NoSuchFieldException
* @throws IOException
*/
@Test
void testTelemetryNotSentExecute() throws NoSuchFieldException, IOException {
setup(false, DecisioningMethod.ON_DEVICE, "testTelemetryNotSentExecute");
TargetService targetServiceMock = mock(TargetService.class, RETURNS_DEFAULTS);
NotificationService notificationService = new NotificationService(targetServiceMock, clientConfig, clusterLocator);
FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), notificationService);
fileRuleLoader("DECISIONING_PAYLOAD_ALL_MATCHES.json", localService);
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(new Context().channel(ChannelType.WEB)).execute(new ExecuteRequest().addMboxesItem(new MboxRequest().index(0).name("allmatches"))).prefetch(new PrefetchRequest().addMboxesItem(new MboxRequest().index(0).name("TEST_PREFETCH"))).decisioningMethod(DecisioningMethod.ON_DEVICE).build();
targetJavaClient.getOffers(targetDeliveryRequest);
ArgumentCaptor<TargetDeliveryRequest> captor = ArgumentCaptor.forClass(TargetDeliveryRequest.class);
verify(targetServiceMock, timeout(1000)).executeNotificationAsync(captor.capture());
Telemetry telemetry = captor.getValue().getDeliveryRequest().getTelemetry();
List<Notification> notifications = captor.getValue().getDeliveryRequest().getNotifications();
assertNull(telemetry);
assertEquals(notifications.size(), 1);
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluatorTest method testAllLocalNoRemoteAllViews.
@Test
public void testAllLocalNoRemoteAllViews() throws JsonProcessingException, NoSuchFieldException {
OnDeviceDecisioningRuleSet ruleSet = new OnDeviceDecisioningRuleSet();
List<String> localViews = new ArrayList<>();
localViews.add("test");
localViews.add("test2");
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("localViews"), localViews);
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("remoteViews"), new ArrayList<String>());
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);
assertTrue(evaluation.isAllLocal());
assertNull(evaluation.getRemoteMBoxes());
assertNull(evaluation.getRemoteViews());
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class TelemetryService method isPrefetchPageLoad.
private Boolean isPrefetchPageLoad(TargetDeliveryRequest request) {
boolean prefetchPageLoad = false;
PrefetchRequest prefetchRequest = request.getDeliveryRequest().getPrefetch();
if (prefetchRequest != null) {
prefetchPageLoad = prefetchRequest.getPageLoad() != null;
}
return prefetchPageLoad;
}
Aggregations