Search in sources :

Example 1 with ExecutionMode

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());
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) Property(com.adobe.target.delivery.v1.model.Property) Test(org.junit.jupiter.api.Test)

Example 2 with ExecutionMode

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());
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) Property(com.adobe.target.delivery.v1.model.Property) Test(org.junit.jupiter.api.Test)

Example 3 with ExecutionMode

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());
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) Property(com.adobe.target.delivery.v1.model.Property) Test(org.junit.jupiter.api.Test)

Example 4 with ExecutionMode

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());
}
Also used : TelemetryFeatures(com.adobe.target.delivery.v1.model.TelemetryFeatures) ExecutionMode(com.adobe.target.delivery.v1.model.ExecutionMode) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry)

Aggregations

TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 Context (com.adobe.target.delivery.v1.model.Context)3 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)3 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)3 Property (com.adobe.target.delivery.v1.model.Property)3 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)3 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)3 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)3 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)3 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)3 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)3 TimingTool (com.adobe.target.edge.client.utils.TimingTool)3 Test (org.junit.jupiter.api.Test)3 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)2 ExecutionMode (com.adobe.target.delivery.v1.model.ExecutionMode)1 TelemetryFeatures (com.adobe.target.delivery.v1.model.TelemetryFeatures)1