use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithNonDefaultProperty.
@Test
void testTargetDeliveryRequestWithNonDefaultProperty() throws NoSuchFieldException {
setup(true);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
String nonDefaultToken = "non-default-token";
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).build();
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
DeliveryRequest finalRequest = targetDeliveryResponse.getRequest();
assertEquals(nonDefaultToken, finalRequest.getProperty().getToken());
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithoutCookies.
@Test
void testTargetDeliveryRequestWithoutCookies() throws NoSuchFieldException {
setup(true);
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
Map<String, CustomerState> customerIds = getCustomerIds();
List<Notification> mboxNotifications = getMboxNotifications();
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).customerIds(customerIds).notifications(mboxNotifications).trackingServer(TEST_TRACKING_SERVER).thirdPartyId(TEST_THIRD_PARTY_ID).build();
String newSessionId = targetDeliveryRequest.getSessionId();
assertNotNull(newSessionId);
VisitorId id = targetDeliveryRequest.getDeliveryRequest().getId();
assertNull(id.getTntId());
assertEquals(TEST_THIRD_PARTY_ID, id.getThirdPartyId());
assertNull(id.getMarketingCloudVisitorId());
validateCustomerId(customerIds, id.getCustomerIds());
assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
verifyAnalyticsValues(targetDeliveryRequest);
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
verifyServerStateAndNewCookie(targetDeliveryResponse, newSessionId);
verifyVisitorState(targetDeliveryResponse, customerIds);
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluatorTest method testAllLocalNoRemoteView.
@Test
public void testAllLocalNoRemoteView() 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().name("test")).addViewsItem(new ViewRequest().name("test2"))).build();
OnDeviceDecisioningEvaluation evaluation = evaluator.evaluateLocalExecution(request);
assertTrue(evaluation.isAllLocal());
assertNull(evaluation.getRemoteMBoxes());
assertNull(evaluation.getRemoteViews());
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class DefaultTargetServiceTest method getDeliveryRequest.
private TargetDeliveryRequest getDeliveryRequest() {
Context context = getLocalContext();
PrefetchRequest prefetchRequest = getMboxPrefetchLocalRequest("testoffer");
ExecuteRequest executeRequest = getMboxExecuteLocalRequest("testoffer2");
VisitorId visitorId = new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916873");
Notification notification = new Notification();
notification.setId(UUID.randomUUID().toString());
notification.setImpressionId(UUID.randomUUID().toString());
notification.setType(MetricType.DISPLAY);
notification.setTimestamp(System.currentTimeMillis());
notification.setTokens(Collections.singletonList("IbG2Jz2xmHaqX7Ml/YRxRGqipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q=="));
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).id(visitorId).notifications(Collections.singletonList(notification)).build();
return targetDeliveryRequest;
}
use of com.adobe.target.edge.client.model.TargetDeliveryRequest in project target-java-sdk by adobe.
the class DefaultTargetServiceTest method testExecuteNotification.
/**
* executeNotification(args) method also calls private method callDeliveryApi(), we can check if
* the targetHttpClient inside callDeliveryApi() is called within the method.
*/
@Test
public void testExecuteNotification() {
ResponseWrapper<DeliveryResponse> mockedResponseWrapper = getTestDeliveryResponse();
getMockedTelemetry();
Mockito.lenient().doReturn(mockedResponseWrapper).when(targetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
TargetDeliveryRequest targetDeliveryRequestMock = getDeliveryRequest();
targetService.executeNotification(targetDeliveryRequestMock);
verify(targetHttpClient, times(1)).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
}
Aggregations