Skip to content

Commit 01851ea

Browse files
committed
Add missing unit test to reach 100%
Signed-off-by: huy pham <huyp@amazon.com>
1 parent bb4ffb0 commit 01851ea

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • data-prepper-plugins/otlp-sink/src/test/java/org/opensearch/dataprepper/plugins/sink/otlp/http

data-prepper-plugins/otlp-sink/src/test/java/org/opensearch/dataprepper/plugins/sink/otlp/http/OtlpHttpSenderTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,20 @@ void testHandleSuccessfulResponse_privateMethod_parseException() throws Exceptio
422422
verify(mockEventHandle2).release(true);
423423
verify(mockEventHandle3).release(true);
424424
}
425+
426+
@Test
427+
void testHandleResponse_withNullResponseBody_logsNoBody() throws Exception {
428+
final Method method = OtlpHttpSender.class.getDeclaredMethod("handleResponse", int.class, byte[].class, List.class);
429+
method.setAccessible(true);
430+
431+
method.invoke(sender, 500, null, testBatch);
432+
433+
verify(metrics).recordResponseCode(500);
434+
verify(metrics).incrementRejectedSpansCount(SPANS_COUNT);
435+
436+
// Verifying event handles released with success=false
437+
verify(mockEventHandle1).release(false);
438+
verify(mockEventHandle2).release(false);
439+
verify(mockEventHandle3).release(false);
440+
}
425441
}

0 commit comments

Comments
 (0)