Search in sources :

Example 6 with DeliveryResponse

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

the class DefaultTargetServiceTest method testExecuteNotification.

/**
 * executeNotification(args) method also calls private method callDeliveryApi(), we can check if
 * the targetHttpClient inside callDeliveryApi() is called within the method.
 */
@Test
public void testExecuteNotification() {
    ResponseWrapper<DeliveryResponse> mockedResponseWrapper = getTestDeliveryResponse();
    getMockedTelemetry();
    Mockito.lenient().doReturn(mockedResponseWrapper).when(targetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    TargetDeliveryRequest targetDeliveryRequestMock = getDeliveryRequest();
    targetService.executeNotification(targetDeliveryRequestMock);
    verify(targetHttpClient, times(1)).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 7 with DeliveryResponse

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

the class DefaultTargetServiceTest method testExecuteRequestCallToDeliveryApi.

/**
 * since callDeliveryApi() is private, we can check if the targetHttpClient inside
 * callDeliveryApi() is called from our test method
 */
@Test
public void testExecuteRequestCallToDeliveryApi() {
    ResponseWrapper<DeliveryResponse> mockedResponseWrapper = getTestDeliveryResponse();
    getMockedTelemetry();
    Mockito.lenient().doReturn(mockedResponseWrapper).when(targetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    TargetDeliveryRequest targetDeliveryRequestMock = getDeliveryRequest();
    targetService.executeRequest(targetDeliveryRequestMock);
    verify(targetHttpClient, times(1)).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 8 with DeliveryResponse

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

the class TelemetryServiceTest method testAddTelemetryForServerSide.

/**
 * Checking all telemetryEntry features which gets added for server side decisioning
 *
 * @throws NoSuchFieldException
 */
@Test
void testAddTelemetryForServerSide() throws NoSuchFieldException {
    setup(true, DecisioningMethod.SERVER_SIDE, "testAddTelemetryForServerSide");
    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");
    deliveryResponse.setEdgeHost("mboxedge35.tt.omtrdc.net");
    TargetDeliveryResponse targetDeliveryResponse = new TargetDeliveryResponse(targetDeliveryRequest, deliveryResponse, 200, "test call");
    targetDeliveryResponse.getResponse().setRequestId("testID");
    targetDeliveryResponse.getResponse().setTelemetryServerToken("testServerToken2022");
    telemetryServiceSpy.addTelemetry(targetDeliveryRequest, timer, targetDeliveryResponse);
    TelemetryEntry telemetryEntry = telemetryServiceSpy.getTelemetry().getEntries().get(0);
    assertNotNull(telemetryEntry);
    assertEquals(3, telemetryEntry.getFeatures().getExecuteMboxCount());
    assertEquals(1, telemetryEntry.getFeatures().getPrefetchViewCount());
    assertEquals(true, telemetryEntry.getFeatures().getExecutePageLoad());
    assertEquals(true, telemetryEntry.getFeatures().getPrefetchPageLoad());
    assertEquals(3, telemetryEntry.getFeatures().getPrefetchMboxCount());
    assertEquals("testID", telemetryEntry.getRequestId());
    assertEquals("testServerToken2022", telemetryEntry.getTelemetryServerToken());
    assertEquals(ExecutionMode.EDGE, telemetryEntry.getMode());
    assertEquals(DecisioningMethod.SERVER_SIDE.toString(), telemetryEntry.getFeatures().getDecisioningMethod());
}
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 9 with DeliveryResponse

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

the class TelemetryServiceTest method testExecutionModeForServerSide.

@Test
void testExecutionModeForServerSide() throws NoSuchFieldException {
    setup(true, DecisioningMethod.SERVER_SIDE, "testExecutionModeServerSide");
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).decisioningMethod(DecisioningMethod.SERVER_SIDE).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);
    Telemetry telemetry = telemetryServiceSpy.getTelemetry();
    assertEquals(ExecutionMode.EDGE, telemetry.getEntries().get(0).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) 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) Telemetry(com.adobe.target.delivery.v1.model.Telemetry) Test(org.junit.jupiter.api.Test)

Example 10 with DeliveryResponse

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

Aggregations

DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)15 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)12 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)11 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)10 TimingTool (com.adobe.target.edge.client.utils.TimingTool)10 Test (org.junit.jupiter.api.Test)10 Context (com.adobe.target.delivery.v1.model.Context)6 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)6 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)6 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)6 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)6 DeliveryRequest (com.adobe.target.delivery.v1.model.DeliveryRequest)5 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)5 Property (com.adobe.target.delivery.v1.model.Property)5 Map (java.util.Map)5 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)4 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 ExecuteResponse (com.adobe.target.delivery.v1.model.ExecuteResponse)2 PrefetchResponse (com.adobe.target.delivery.v1.model.PrefetchResponse)2 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)2