Search in sources :

Example 16 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry 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);
}
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) MboxRequest(com.adobe.target.delivery.v1.model.MboxRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Telemetry(com.adobe.target.delivery.v1.model.Telemetry) Notification(com.adobe.target.delivery.v1.model.Notification) Test(org.junit.jupiter.api.Test)

Example 17 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.

the class DefaultTargetService method executeRequest.

@Override
public TargetDeliveryResponse executeRequest(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    TargetDeliveryResponse targetDeliveryResponse;
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    ResponseWrapper<DeliveryResponse> response = callDeliveryApi(deliveryRequest);
    targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
    /* capture Telemetry information once original request's response is received */
    telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
    return targetDeliveryResponse;
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) Telemetry(com.adobe.target.delivery.v1.model.Telemetry) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse)

Aggregations

Context (com.adobe.target.delivery.v1.model.Context)11 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)11 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)11 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)11 TimingTool (com.adobe.target.edge.client.utils.TimingTool)11 Test (org.junit.jupiter.api.Test)11 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)10 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)9 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)9 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)9 MboxRequest (com.adobe.target.delivery.v1.model.MboxRequest)5 Property (com.adobe.target.delivery.v1.model.Property)4 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)3 ResponseWrapper (com.adobe.target.edge.client.http.ResponseWrapper)3 Notification (com.adobe.target.delivery.v1.model.Notification)2 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)2 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)2 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)2 ArrayList (java.util.ArrayList)2