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