|
12 | 12 | import com.getyourguide.openapi.validation.api.model.OpenApiViolation; |
13 | 13 | import java.util.List; |
14 | 14 | import org.junit.jupiter.api.Test; |
| 15 | +import org.junit.jupiter.params.ParameterizedTest; |
| 16 | +import org.junit.jupiter.params.provider.ValueSource; |
15 | 17 | import org.springframework.web.server.ResponseStatusException; |
16 | 18 |
|
17 | 19 | class OpenApiValidationInterceptorTest extends BaseFilterTest { |
@@ -104,15 +106,16 @@ public void testShouldFailOnRequestViolationWithViolation() { |
104 | 106 | verifyNoResponseValidation(); |
105 | 107 | } |
106 | 108 |
|
107 | | - @Test |
108 | | - public void testShouldIgnoreBodyOnGetRequests() { |
109 | | - var mockData = mockSetup(MockConfiguration.builder().requestBody("{\"field\": 1}}").requestMethod("GET").build()); |
| 109 | + @ParameterizedTest |
| 110 | + @ValueSource(strings = {"GET", "POST", "PUT", "PATCH", "DELETE"}) |
| 111 | + public void testShouldSupportBodyOnGetRequests(String requestMethod) { |
| 112 | + var mockData = mockSetup(MockConfiguration.builder().requestBody("{\"field\": 1}}").requestMethod(requestMethod).build()); |
110 | 113 |
|
111 | 114 | httpInterceptor.preHandle(mockData.request(), mockData.response(), new Object()); |
112 | 115 | httpInterceptor.postHandle(mockData.request(), mockData.response(), new Object(), null); |
113 | 116 | httpInterceptor.afterCompletion(mockData.request(), mockData.response(), new Object(), null); |
114 | 117 |
|
115 | | - verifyRequestValidatedAsync(mockData, null); |
| 118 | + verifyRequestValidatedAsync(mockData, "{\"field\": 1}}"); |
116 | 119 | verifyResponseValidatedAsync(mockData); |
117 | 120 | } |
118 | 121 |
|
|
0 commit comments