Search in sources :

Example 31 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testWhenNoTelemetryEnabledForServerSide.

@Test
void testWhenNoTelemetryEnabledForServerSide() throws NoSuchFieldException {
    setup(false);
    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();
    targetJavaClient.getOffers(targetDeliveryRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNotNull(targetDeliveryResponse);
    assertNotNull(targetDeliveryResponse.getRequest());
    assertNull(targetDeliveryResponse.getRequest().getTelemetry());
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 32 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithCookies.

@Test
void testTargetDeliveryRequestWithCookies() throws NoSuchFieldException {
    setup(true);
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    Map<String, CustomerState> customerIds = getCustomerIds();
    List<Notification> mboxNotifications = getMboxNotifications();
    List<TargetCookie> testCookies = getTestCookies();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).customerIds(customerIds).notifications(mboxNotifications).trackingServer(TEST_TRACKING_SERVER).cookies(testCookies).thirdPartyId(TEST_THIRD_PARTY_ID).build();
    assertEquals(TEST_SESSION_ID, targetDeliveryRequest.getSessionId());
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
    verifyId(customerIds, targetDeliveryRequest);
    verifyVisitorValues(targetDeliveryRequest);
    verifyAnalyticsValues(targetDeliveryRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    verifyServerStateAndNewCookie(targetDeliveryResponse, TEST_SESSION_ID);
    verifyVisitorState(targetDeliveryResponse, customerIds);
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetCookie(com.adobe.target.edge.client.model.TargetCookie) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 33 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithNonDefaultProperty.

@Test
void testTargetDeliveryRequestWithNonDefaultProperty() throws NoSuchFieldException {
    setup(true);
    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)).build();
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    DeliveryRequest finalRequest = targetDeliveryResponse.getRequest();
    assertEquals(nonDefaultToken, finalRequest.getProperty().getToken());
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 34 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class TargetDeliveryRequestTest method testTargetDeliveryRequestWithoutCookies.

@Test
void testTargetDeliveryRequestWithoutCookies() throws NoSuchFieldException {
    setup(true);
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    Map<String, CustomerState> customerIds = getCustomerIds();
    List<Notification> mboxNotifications = getMboxNotifications();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).customerIds(customerIds).notifications(mboxNotifications).trackingServer(TEST_TRACKING_SERVER).thirdPartyId(TEST_THIRD_PARTY_ID).build();
    String newSessionId = targetDeliveryRequest.getSessionId();
    assertNotNull(newSessionId);
    VisitorId id = targetDeliveryRequest.getDeliveryRequest().getId();
    assertNull(id.getTntId());
    assertEquals(TEST_THIRD_PARTY_ID, id.getThirdPartyId());
    assertNull(id.getMarketingCloudVisitorId());
    validateCustomerId(customerIds, id.getCustomerIds());
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(executeRequest, targetDeliveryRequest.getDeliveryRequest().getExecute());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    assertEquals(mboxNotifications, targetDeliveryRequest.getDeliveryRequest().getNotifications());
    verifyAnalyticsValues(targetDeliveryRequest);
    TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    verifyServerStateAndNewCookie(targetDeliveryResponse, newSessionId);
    verifyVisitorState(targetDeliveryResponse, customerIds);
}
Also used : CustomerState(com.adobe.experiencecloud.ecid.visitor.CustomerState) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 35 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class TelemetryServiceTest method testTelemetryForServerSide.

/**
 * Test case to call get offers for server side, in first request we capture the telemetry & in
 * next call we send it with any getOffers() call or sendNotifications() call
 *
 * @throws NoSuchFieldException
 */
@Test
void testTelemetryForServerSide() throws NoSuchFieldException {
    setup(true, DecisioningMethod.SERVER_SIDE, "testTelemetryForServerSide");
    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();
    TargetDeliveryResponse targetDeliveryResponse1 = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNull(targetDeliveryResponse1.getRequest().getTelemetry());
    // In next call we see telemetry data added to the deliveryRequest
    TargetDeliveryResponse targetDeliveryResponse2 = targetJavaClient.getOffers(targetDeliveryRequest);
    verify(telemetryServiceSpy, atLeast(2)).getTelemetry();
    verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
    assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
    assertNotNull(targetDeliveryResponse2);
    assertNotNull(targetDeliveryResponse2.getRequest());
    assertNotNull(targetDeliveryResponse2.getRequest().getTelemetry());
    assertEquals(1, targetDeliveryResponse2.getRequest().getTelemetry().getEntries().size());
}
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) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Property(com.adobe.target.delivery.v1.model.Property) Test(org.junit.jupiter.api.Test)

Aggregations

TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)66 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)58 Test (org.junit.jupiter.api.Test)53 TimingTool (com.adobe.target.edge.client.utils.TimingTool)13 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)10 Context (com.adobe.target.delivery.v1.model.Context)9 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)9 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)9 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)9 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)9 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)8 Property (com.adobe.target.delivery.v1.model.Property)7 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)6 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)5 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 ParamsCollator (com.adobe.target.edge.client.ondevice.collator.ParamsCollator)4 CustomerState (com.adobe.experiencecloud.ecid.visitor.CustomerState)3 TargetRequestException (com.adobe.target.edge.client.exception.TargetRequestException)3 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)3 ResponseWrapper (com.adobe.target.edge.client.http.ResponseWrapper)3