use of com.adobe.target.delivery.v1.model.ExecutionMode in project target-java-sdk by adobe.
the class TelemetryServiceTest method testExecutionModeForHybridWithNotAllLocal.
/**
* Test to verify telemetryEntry has correct executionMode For hybrid & status 200 we should have
* mode as local
*
* @throws NoSuchFieldException
*/
@Test
void testExecutionModeForHybridWithNotAllLocal() throws NoSuchFieldException {
setup(true, DecisioningMethod.HYBRID, "testExecutionModeHybridWithNotALlLocal");
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.HYBRID).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
deliveryResponse.setEdgeHost("mboxedge35.tt.omtrdc.net");
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.EDGE, telemetryEntry.getMode());
}
use of com.adobe.target.delivery.v1.model.ExecutionMode in project target-java-sdk by adobe.
the class TelemetryServiceTest method testExecutionModeForHybridWithAllLocal.
/**
* Test to verify telemetryEntry has correct executionMode With partial content 206 status &
* hybrid our mode should be edge
*
* @throws NoSuchFieldException
*/
@Test
void testExecutionModeForHybridWithAllLocal() throws NoSuchFieldException {
setup(true, DecisioningMethod.HYBRID, "testExecutionModeHybridWithAllLocal");
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
Context context = getContext();
ExecuteRequest executeRequest = getMboxExecuteRequest();
String nonDefaultToken = "non-default-token";
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.HYBRID).build();
DeliveryResponse deliveryResponse = new DeliveryResponse();
deliveryResponse.setClient("SUMMIT_TEST2021");
deliveryResponse.setEdgeHost(null);
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.ExecutionMode 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.ExecutionMode in project target-java-sdk by adobe.
the class TelemetryService method createTelemetryEntry.
private TelemetryEntry createTelemetryEntry(TargetDeliveryRequest targetDeliveryRequest, TargetDeliveryResponse targetDeliveryResponse, double executionTime) {
if (!clientConfig.isTelemetryEnabled() || targetDeliveryResponse.getResponse() == null) {
return null;
}
TelemetryFeatures telemetryFeatures = buildTelemetryFeatures(targetDeliveryRequest);
ExecutionMode executionMode = getMode(targetDeliveryResponse);
return new TelemetryEntry().requestId(targetDeliveryResponse.getResponse().getRequestId()).telemetryServerToken(targetDeliveryResponse.getResponse().getTelemetryServerToken()).mode(executionMode).features(telemetryFeatures).execution(MathUtils.roundDouble(executionTime, DECIMAL_PLACES)).timestamp(System.currentTimeMillis());
}
Aggregations