Search in sources :

Example 1 with TargetDeliveryRequestBuilder

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

the class TargetDeliveryRequestLocalViewTest method localDeliveryRequest.

private TargetDeliveryRequest localDeliveryRequest(String visitorIdStr, List<String> views, boolean execute) {
    Context context = getLocalContext();
    context.setAddress(new Address().url("http://local-target-test/"));
    PrefetchRequest prefetchRequest = new PrefetchRequest();
    if (views != null) {
        if (views.isEmpty()) {
            prefetchRequest.addViewsItem(new ViewRequest());
        } else {
            for (String viewName : views) {
                prefetchRequest.addViewsItem(new ViewRequest().name(viewName));
            }
        }
    } else {
        prefetchRequest.setPageLoad(new RequestDetails());
    }
    ExecuteRequest executeRequest = null;
    if (execute) {
        executeRequest = new ExecuteRequest();
        executeRequest.setPageLoad(new RequestDetails());
    }
    VisitorId visitorId = new VisitorId().tntId(visitorIdStr);
    TargetDeliveryRequestBuilder targetDeliveryRequestBuilder = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).id(visitorId).decisioningMethod(DecisioningMethod.ON_DEVICE);
    if (execute) {
        targetDeliveryRequestBuilder.execute(executeRequest);
    }
    TargetDeliveryRequest targetDeliveryRequest = targetDeliveryRequestBuilder.build();
    assertEquals(prefetchRequest, targetDeliveryRequest.getDeliveryRequest().getPrefetch());
    assertEquals(context, targetDeliveryRequest.getDeliveryRequest().getContext());
    return targetDeliveryRequest;
}
Also used : TargetTestDeliveryRequestUtils.getLocalContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getLocalContext) TargetDeliveryRequestBuilder(com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest)

Example 2 with TargetDeliveryRequestBuilder

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

the class TargetDeliveryLocalPropertyTest method optionsForProperty.

@SuppressWarnings("unchecked")
private List<Option> optionsForProperty(String propertyToken, boolean noProperty) {
    TargetDeliveryRequestBuilder builder = TargetDeliveryRequest.builder().context(new Context().address(new Address().url("https://test.com"))).prefetch(new PrefetchRequest().addMboxesItem(new MboxRequest().name("superfluous-mbox").index(0))).id(new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916874")).decisioningMethod(DecisioningMethod.HYBRID);
    if (!noProperty) {
        builder.property(new Property().token(propertyToken));
    }
    TargetDeliveryRequest targetDeliveryRequest = builder.build();
    TargetDeliveryResponse response = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNotNull(response);
    assertEquals(200, response.getStatus());
    verify(defaultTargetHttpClient, never()).execute(any(Map.class), any(String.class), eq(targetDeliveryRequest), any(Class.class));
    DeliveryResponse deliveryResponse = response.getResponse();
    assertNotNull(deliveryResponse);
    PrefetchResponse prefetchResponse = deliveryResponse.getPrefetch();
    assertNotNull(prefetchResponse);
    List<PrefetchMboxResponse> mboxResponses = prefetchResponse.getMboxes();
    assertNotNull(mboxResponses);
    assertEquals(1, mboxResponses.size());
    PrefetchMboxResponse mboxResponse = mboxResponses.get(0);
    assertNotNull(mboxResponse);
    assertEquals(0, mboxResponse.getIndex());
    assertEquals("superfluous-mbox", mboxResponse.getName());
    return mboxResponse.getOptions();
}
Also used : TargetDeliveryRequestBuilder(com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetTestDeliveryRequestUtils.getTestDeliveryResponse(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Map(java.util.Map)

Aggregations

TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)2 TargetDeliveryRequestBuilder (com.adobe.target.edge.client.model.TargetDeliveryRequestBuilder)2 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)1 TargetTestDeliveryRequestUtils.getLocalContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getLocalContext)1 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)1 Map (java.util.Map)1