Search in sources :

Example 6 with TelemetryEntry

use of com.adobe.target.delivery.v1.model.TelemetryEntry 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 7 with TelemetryEntry

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

the class DefaultTargetServiceTest method getMockedTelemetry.

private void getMockedTelemetry() {
    Telemetry telemetryMock = new Telemetry();
    TelemetryEntry telemetryEntryMock = new TelemetryEntry();
    telemetryEntryMock.setRequestId("test123");
    telemetryEntryMock.setTimestamp(System.currentTimeMillis());
    telemetryMock.addEntriesItem(telemetryEntryMock);
    Mockito.lenient().when(telemetryService.getTelemetry()).thenReturn(telemetryMock);
}
Also used : TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 8 with TelemetryEntry

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

the class TelemetryServiceTest method testTelemetrySentOnPrefetch.

/**
 * Check telemetryEntry in prefetch call
 *
 * @throws NoSuchFieldException
 * @throws IOException
 */
@Test
void testTelemetrySentOnPrefetch() throws NoSuchFieldException, IOException {
    setup(true, DecisioningMethod.ON_DEVICE, "testTelemetrySentOnPrefetch");
    long timestamp = System.currentTimeMillis();
    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);
    Telemetry telemetry = telemetryServiceSpy.getTelemetry();
    assertNotNull(telemetry);
    TelemetryEntry telemetryEntry = telemetry.getEntries().get(1);
    assertTrue(telemetryEntry.getTimestamp() > timestamp);
    assertTrue(telemetryEntry.getExecution() > 0);
    assertTrue(telemetryEntry.getRequestId().length() > 0);
    assertEquals(telemetryEntry.getFeatures().getDecisioningMethod(), "on-device");
}
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) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) Telemetry(com.adobe.target.delivery.v1.model.Telemetry) Test(org.junit.jupiter.api.Test)

Example 9 with TelemetryEntry

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

the class TelemetryServiceTest method testTelemetrySentOnExecute.

/**
 * Check telemetryEntry in execute call
 *
 * @throws NoSuchFieldException
 * @throws IOException
 */
@Test
void testTelemetrySentOnExecute() throws NoSuchFieldException, IOException {
    setup(true, DecisioningMethod.ON_DEVICE, "testTelemetrySentOnExecute");
    long timestamp = System.currentTimeMillis();
    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 = telemetryServiceSpy.getTelemetry();
    assertNotNull(telemetry);
    assertEquals(telemetry.getEntries().size(), 2);
    TelemetryEntry telemetryEntry = telemetry.getEntries().get(1);
    assertTrue(telemetryEntry.getTimestamp() > timestamp);
    assertTrue(telemetryEntry.getExecution() > 0);
    assertTrue(telemetryEntry.getRequestId().length() > 0);
    assertEquals(telemetryEntry.getFeatures().getDecisioningMethod(), "on-device");
}
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) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) Telemetry(com.adobe.target.delivery.v1.model.Telemetry) Test(org.junit.jupiter.api.Test)

Example 10 with TelemetryEntry

use of com.adobe.target.delivery.v1.model.TelemetryEntry 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)

Aggregations

TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)12 Context (com.adobe.target.delivery.v1.model.Context)6 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)6 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)6 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)6 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)6 Test (org.junit.jupiter.api.Test)6 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)5 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)4 Property (com.adobe.target.delivery.v1.model.Property)4 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)4 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)4 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)4 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)4 TimingTool (com.adobe.target.edge.client.utils.TimingTool)4 MboxRequest (com.adobe.target.delivery.v1.model.MboxRequest)2 ExecutionMode (com.adobe.target.delivery.v1.model.ExecutionMode)1 TelemetryFeatures (com.adobe.target.delivery.v1.model.TelemetryFeatures)1 TelemetryRequest (com.adobe.target.delivery.v1.model.TelemetryRequest)1 ArrayList (java.util.ArrayList)1