Search in sources :

Example 1 with TargetRequestException

use of com.adobe.target.edge.client.exception.TargetRequestException in project target-java-sdk by adobe.

the class TargetDeliveryExceptionTest method testTargetDeliveryRequest.

@Test
void testTargetDeliveryRequest() {
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).build();
    TargetRequestException exception = assertThrows(TargetRequestException.class, () -> {
        TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
    });
    assertNotNull(exception);
    assertNotNull(exception.getRequest());
    assertNotNull(exception.getRequest().getSessionId());
}
Also used : TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) Context(com.adobe.target.delivery.v1.model.Context) 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) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 2 with TargetRequestException

use of com.adobe.target.edge.client.exception.TargetRequestException in project target-java-sdk by adobe.

the class DefaultTargetClient method getOffers.

@Override
public TargetDeliveryResponse getOffers(TargetDeliveryRequest request) {
    try {
        Objects.requireNonNull(request, "request cannot be null");
        TargetDeliveryResponse targetDeliveryResponse;
        DecisioningMethod decisioningMethod = getDecisioningMethod(request);
        updatePropertyToken(request);
        if (decisioningMethod == DecisioningMethod.ON_DEVICE || (decisioningMethod == DecisioningMethod.HYBRID && localService.evaluateLocalExecution(request).isAllLocal())) {
            targetDeliveryResponse = localService.executeRequest(request);
        } else {
            targetDeliveryResponse = targetService.executeRequest(request);
        }
        return targetDeliveryResponse;
    } catch (Exception e) {
        TargetRequestException targetRequestException = new TargetRequestException(e.getMessage(), e, request);
        logger.error(targetRequestException.getMessage());
        throw targetRequestException;
    }
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException) DecisioningMethod(com.adobe.target.edge.client.model.DecisioningMethod) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException)

Example 3 with TargetRequestException

use of com.adobe.target.edge.client.exception.TargetRequestException in project target-java-sdk by adobe.

the class DefaultTargetClient method getOffersAsync.

@Override
public CompletableFuture<TargetDeliveryResponse> getOffersAsync(TargetDeliveryRequest request) {
    try {
        Objects.requireNonNull(request, "request cannot be null");
        CompletableFuture<TargetDeliveryResponse> targetDeliveryResponse;
        DecisioningMethod decisioningMethod = getDecisioningMethod(request);
        updatePropertyToken(request);
        if (decisioningMethod == DecisioningMethod.ON_DEVICE || (decisioningMethod == DecisioningMethod.HYBRID && localService.evaluateLocalExecution(request).isAllLocal())) {
            targetDeliveryResponse = localService.executeRequestAsync(request);
        } else {
            targetDeliveryResponse = targetService.executeRequestAsync(request);
        }
        return targetDeliveryResponse;
    } catch (Exception e) {
        TargetRequestException targetRequestException = new TargetRequestException(e.getMessage(), e, request);
        logger.error(targetRequestException.getMessage());
        throw targetRequestException;
    }
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException) DecisioningMethod(com.adobe.target.edge.client.model.DecisioningMethod) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException)

Aggregations

TargetRequestException (com.adobe.target.edge.client.exception.TargetRequestException)3 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)3 DecisioningMethod (com.adobe.target.edge.client.model.DecisioningMethod)2 Context (com.adobe.target.delivery.v1.model.Context)1 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)1 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)1 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)1 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)1 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)1 Test (org.junit.jupiter.api.Test)1