diff --git a/src/test/java/org/sitmun/proxy/middleware/protocols/http/HttpRequestDecoratorAddBodyTest.java b/src/test/java/org/sitmun/proxy/middleware/protocols/http/HttpRequestDecoratorAddBodyTest.java
index 46efacd..4a725ba 100644
--- a/src/test/java/org/sitmun/proxy/middleware/protocols/http/HttpRequestDecoratorAddBodyTest.java
+++ b/src/test/java/org/sitmun/proxy/middleware/protocols/http/HttpRequestDecoratorAddBodyTest.java
@@ -1,6 +1,7 @@
package org.sitmun.proxy.middleware.protocols.http;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.BeforeEach;
@@ -27,63 +28,50 @@ void setUp() {
@Test
@DisplayName("Should accept when context is payload with POST method and non-null body")
- void shouldAcceptWhenContextIsWmsPayloadDtoWithPostMethodAndNonNullBody() {
- // Given
+ void shouldAcceptWhenContextIsHttpContextWithPostMethodAndNonNullBody() {
when(httpContext.getMethod()).thenReturn("POST");
when(httpContext.getBody()).thenReturn("data");
- // When
boolean result = decorator.accept(requestExecutor, httpContext);
- // Then
assertThat(result).isTrue();
}
@Test
@DisplayName("Should not accept when context is payload with GET method")
- void shouldNotAcceptWhenContextIsWmsPayloadDtoWithGetMethod() {
- // Given
+ void shouldNotAcceptWhenContextIsHttpContextWithGetMethod() {
when(httpContext.getMethod()).thenReturn("GET");
- // When
boolean result = decorator.accept(requestExecutor, httpContext);
- // Then
assertThat(result).isFalse();
}
@Test
@DisplayName("Should not accept when context is payload with POST method but null body")
- void shouldNotAcceptWhenContextIsWmsPayloadDtoWithPostMethodButNullBody() {
- // Given
+ void shouldNotAcceptWhenContextIsHttpContextWithPostMethodButNullBody() {
when(httpContext.getMethod()).thenReturn("POST");
when(httpContext.getBody()).thenReturn(null);
- // When
boolean result = decorator.accept(requestExecutor, httpContext);
- // Then
assertThat(result).isFalse();
}
@Test
@DisplayName("Should accept when context is payload with POST method and empty body")
- void shouldAcceptWhenContextIsWmsPayloadDtoWithPostMethodAndEmptyBody() {
- // Given
+ void shouldAcceptWhenContextIsHttpContextWithPostMethodAndEmptyBody() {
when(httpContext.getMethod()).thenReturn("POST");
when(httpContext.getBody()).thenReturn("");
- // When
boolean result = decorator.accept(requestExecutor, httpContext);
- // Then
- assertThat(result).isTrue(); // Implementation only checks for != null, not empty
+ assertThat(result).isTrue();
}
@Test
@DisplayName("Should handle XML body with complex structure")
void shouldHandleXmlBodyWithComplexStructure() {
- // Given
String body =
"""
@@ -109,62 +97,20 @@ void shouldHandleXmlBodyWithComplexStructure() {
when(httpContext.getBody()).thenReturn(body);
- // When
decorator.addBehavior(requestExecutor, httpContext);
- // Then
assertThat(requestExecutor.getHeader("Content-Type")).isEqualTo("application/xml");
+ assertThat(requestExecutor).extracting("body").isEqualTo(body);
}
@Test
- @DisplayName("Should handle XML body with CDATA sections")
- void shouldHandleXmlBodyWithCdataSections() {
- // Given
- String body =
- "This is HTML content