@@ -221,6 +221,49 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
221
221
}
222
222
}
223
223
224
+ @Test
225
+ fun `M start and stop RUM Resource W intercept() {successful request, empty response}` (
226
+ @IntForgery(min = 200 , max = 300 ) statusCode : Int
227
+ ) {
228
+ // Given
229
+ fakeResponseBody = " "
230
+ stubChain(mockChain, statusCode)
231
+ val expectedStartAttrs = emptyMap<String , Any ?>()
232
+ val expectedStopAttrs = mapOf (
233
+ RumAttributes .TRACE_ID to fakeTraceIdAsString,
234
+ RumAttributes .SPAN_ID to fakeSpanId,
235
+ RumAttributes .RULE_PSR to fakeTracingSampleRate / 100
236
+ ) + fakeAttributes
237
+ val mimeType = fakeMediaType?.type
238
+ val kind = when {
239
+ mimeType != null -> RumResourceKind .fromMimeType(mimeType)
240
+ else -> RumResourceKind .NATIVE
241
+ }
242
+
243
+ // When
244
+ testedInterceptor.intercept(mockChain)
245
+
246
+ // Then
247
+ inOrder(rumMonitor.mockInstance) {
248
+ argumentCaptor<ResourceId > {
249
+ verify(rumMonitor.mockInstance).startResource(
250
+ capture(),
251
+ eq(fakeMethod),
252
+ eq(fakeUrl),
253
+ eq(expectedStartAttrs)
254
+ )
255
+ verify(rumMonitor.mockInstance).stopResource(
256
+ capture(),
257
+ eq(statusCode),
258
+ eq(0L ),
259
+ eq(kind),
260
+ eq(expectedStopAttrs)
261
+ )
262
+ assertThat(firstValue).isEqualTo(secondValue)
263
+ }
264
+ }
265
+ }
266
+
224
267
@Test
225
268
fun `M start and stop RUM Resource W intercept() {successful streaming request}` (
226
269
@IntForgery(min = 200 , max = 300 ) statusCode : Int ,
@@ -441,7 +484,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
441
484
verify(rumMonitor.mockInstance).stopResource(
442
485
capture(),
443
486
eq(statusCode),
444
- eq(null ),
487
+ eq(0L ),
445
488
eq(kind),
446
489
eq(expectedStopAttrs)
447
490
)
@@ -538,7 +581,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
538
581
verify(rumMonitor.mockInstance).stopResource(
539
582
capture(),
540
583
eq(statusCode),
541
- eq(null ),
584
+ eq(0L ),
542
585
eq(kind),
543
586
eq(expectedStopAttrs)
544
587
)
@@ -596,8 +639,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
596
639
597
640
@Test
598
641
fun `M start and stop RUM Resource W intercept() {successful request throwing response}` (
599
- @IntForgery(min = 200 , max = 300 ) statusCode : Int ,
600
- forge : Forge
642
+ @IntForgery(min = 200 , max = 300 ) statusCode : Int
601
643
) {
602
644
// Given
603
645
stubChain(mockChain) {
@@ -610,7 +652,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
610
652
.body(object : ResponseBody () {
611
653
override fun contentType (): MediaType ? = fakeMediaType
612
654
613
- override fun contentLength (): Long = forge.anElementFrom( 0 , - 1 )
655
+ override fun contentLength (): Long = - 1L
614
656
615
657
override fun source (): BufferedSource {
616
658
val buffer = Buffer ()
@@ -659,8 +701,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
659
701
660
702
@Test
661
703
fun `M start and stop RUM Resource W intercept() {success request throwing response + !smp}` (
662
- @IntForgery(min = 200 , max = 300 ) statusCode : Int ,
663
- forge : Forge
704
+ @IntForgery(min = 200 , max = 300 ) statusCode : Int
664
705
) {
665
706
// Given
666
707
whenever(mockTraceSampler.sample(any())).thenReturn(false )
@@ -674,7 +715,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
674
715
.body(object : ResponseBody () {
675
716
override fun contentType (): MediaType ? = fakeMediaType
676
717
677
- override fun contentLength (): Long = forge.anElementFrom( 0 , - 1 )
718
+ override fun contentLength (): Long = - 1
678
719
679
720
override fun source (): BufferedSource {
680
721
val buffer = Buffer ()
0 commit comments