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());
}
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;
}
}
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;
}
}
Aggregations