Search in sources :

Example 1 with NotificationMbox

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

the class TelemetryServiceTest method testTelemetryForServerSideSendNotificationNullResponse.

/**
 * Test case for calling sendNotifications() and getting an http timeout. In this case Delivery
 * API will return a null response body, and the SDK will throw a RuntimeException, and not
 * collect telemetry.
 *
 * @throws NoSuchFieldException
 */
@Test
void testTelemetryForServerSideSendNotificationNullResponse() throws NoSuchFieldException {
    setup(true, DecisioningMethod.SERVER_SIDE, "testTelemetryForServerSideSendNotificationNullResponse");
    Mockito.lenient().doReturn(getNoContentDeliveryResponse()).when(defaultTargetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    Context context = getContext();
    List<Notification> notifications = new ArrayList<>();
    Notification notification = new Notification().id("12345").impressionId("12345").mbox(new NotificationMbox().name("test-mbox").state("11111")).type(MetricType.DISPLAY).timestamp(System.currentTimeMillis());
    notifications.add(notification);
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).notifications(notifications).build();
    assertThrows(RuntimeException.class, () -> targetJavaClient.sendNotifications(targetDeliveryRequest));
    verify(telemetryServiceSpy, never()).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) NotificationMbox(com.adobe.target.delivery.v1.model.NotificationMbox) ArrayList(java.util.ArrayList) Notification(com.adobe.target.delivery.v1.model.Notification) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

Context (com.adobe.target.delivery.v1.model.Context)1 DeliveryRequest (com.adobe.target.delivery.v1.model.DeliveryRequest)1 Notification (com.adobe.target.delivery.v1.model.Notification)1 NotificationMbox (com.adobe.target.delivery.v1.model.NotificationMbox)1 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)1 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)1 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)1 TimingTool (com.adobe.target.edge.client.utils.TimingTool)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1