use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testTelemetryForODD.
/**
* First call is for location hint, it goes directly inside executeRequestAsync(). Telemetry
* Service gets called second time inside OnDeviceDecisioningService & third time inside
* targetService.executeNotificationAsync()
*
* @throws NoSuchFieldException
* @throws IOException
*/
@Test
void testTelemetryForODD() throws NoSuchFieldException, IOException {
setup(true, DecisioningMethod.ON_DEVICE, "testTelemetryForODD");
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"))).decisioningMethod(DecisioningMethod.ON_DEVICE).build();
targetJavaClient.getOffers(targetDeliveryRequest);
verify(telemetryServiceSpy, times(2)).getTelemetry();
verify(telemetryServiceSpy, times(1)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class));
verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testTelemetryForHybridServerSideCall.
/**
* Test case with Hybrid decisioning that gets executed server-side. We are verifying telemetry
* call for Hybrid decisioning -> server-side execution mode.
*
* @throws NoSuchFieldException
*/
@Test
void testTelemetryForHybridServerSideCall() throws NoSuchFieldException {
setup(true, DecisioningMethod.HYBRID, "testTelemetryForHybridServerSideCall");
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)).decisioningMethod(DecisioningMethod.HYBRID).build();
targetJavaClient.getOffers(targetDeliveryRequest);
verify(telemetryServiceSpy, atLeast(2)).getTelemetry();
verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testAddTelemetry.
/**
* Verify if telemetry data is added correctly
*
* @throws NoSuchFieldException
*/
@Test
void testAddTelemetry() throws NoSuchFieldException {
setup(true, DecisioningMethod.SERVER_SIDE, "testAddTelemetry");
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
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)).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
targetDeliveryResponse.getResponse().setRequestId("testID");
// empty the in memory stored telemetry
telemetryServiceSpy.getTelemetry();
assertEquals(0, telemetryServiceSpy.getTelemetry().getEntries().size());
telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class TelemetryServiceTest method testExecutionModeForOnDevice.
/**
* Test to verify telemetryEntry has correct executionMode For ODD & status 200 it should be local
*
* @throws NoSuchFieldException
*/
@Test
void testExecutionModeForOnDevice() throws NoSuchFieldException {
setup(true, DecisioningMethod.ON_DEVICE, "testExecutionModeOnDeviceWhenStatusOK");
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
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)).decisioningMethod(DecisioningMethod.ON_DEVICE).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
targetDeliveryResponse.getResponse().setRequestId("testID");
telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
TelemetryEntry telemetryEntry = telemetryServiceSpy.getTelemetry().getEntries().get(1);
assert telemetryEntry != null;
assertEquals(ExecutionMode.LOCAL, telemetryEntry.getMode());
}
use of com.adobe.target.delivery.v1.model.ExecuteRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluatorTest method testLocalAndRemoteMbox.
@Test
public void testLocalAndRemoteMbox() throws JsonProcessingException, NoSuchFieldException {
OnDeviceDecisioningRuleSet ruleSet = new OnDeviceDecisioningRuleSet();
List<String> mboxes = new ArrayList<>();
mboxes.add("test");
mboxes.add("test2");
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("localMboxes"), mboxes);
FieldSetter.setField(ruleSet, ruleSet.getClass().getDeclaredField("remoteMboxes"), mboxes);
String serializedRuleSet = objectMapper.writeValueAsString(ruleSet);
RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoader(serializedRuleSet);
evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
TargetDeliveryRequest request = TargetDeliveryRequest.builder().execute(new ExecuteRequest().addMboxesItem(new MboxRequest().name("test").index(0)).addMboxesItem(new MboxRequest().name("test2").index(1))).build();
OnDeviceDecisioningEvaluation evaluation = evaluator.evaluateLocalExecution(request);
assertFalse(evaluation.isAllLocal());
List<String> remoteMboxes = evaluation.getRemoteMBoxes();
remoteMboxes.sort(Comparator.naturalOrder());
assertEquals(mboxes, remoteMboxes);
assertNull(evaluation.getRemoteViews());
}
Aggregations