|
16 | 16 | package software.amazon.awssdk.http.auth.aws.internal.signer.util; |
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.assertThat; |
| 19 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
19 | 20 | import static software.amazon.awssdk.http.Header.CONTENT_LENGTH; |
20 | 21 | import static software.amazon.awssdk.http.auth.aws.internal.signer.util.SignerConstant.X_AMZ_DECODED_CONTENT_LENGTH; |
21 | 22 |
|
@@ -109,23 +110,16 @@ void computeAndMoveContentLength_async_contentLengthPresent_shouldNotSubscribeTo |
109 | 110 | assertThat(request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH)).contains("10"); |
110 | 111 | } |
111 | 112 |
|
112 | | - @ParameterizedTest |
113 | | - @MethodSource("publishers") |
114 | | - void computeAndMoveContentLength_contentLengthNotPresent_shouldInvokeSubscribe(Flowable<ByteBuffer> publisher, long expectedLength) { |
| 113 | + @Test |
| 114 | + void computeAndMoveContentLength_contentLengthNotPresent_throws() { |
115 | 115 | SdkHttpRequest.Builder request = SdkHttpRequest.builder(); |
116 | 116 |
|
117 | | - if (publisher != null) { |
118 | | - publisher = Mockito.spy(publisher); |
119 | | - } |
120 | | - |
121 | | - SignerUtils.computeAndMoveContentLength(request, publisher).join(); |
| 117 | + Publisher<ByteBuffer> contentPublisher = Flowable.just(ByteBuffer.wrap("content".getBytes(StandardCharsets.UTF_8))); |
122 | 118 |
|
123 | | - if (publisher != null) { |
124 | | - Mockito.verify(publisher, Mockito.times(1)).subscribe(Mockito.any(Subscriber.class)); |
125 | | - } |
| 119 | + assertThatThrownBy(() -> SignerUtils.computeAndMoveContentLength(request, contentPublisher).join()) |
| 120 | + .isInstanceOf(UnsupportedOperationException.class) |
| 121 | + .hasMessage("Content-Length header must be specified"); |
126 | 122 |
|
127 | | - assertThat(request.firstMatchingHeader(CONTENT_LENGTH)).isEmpty(); |
128 | | - assertThat(request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH)).contains(String.valueOf(expectedLength)); |
129 | 123 | } |
130 | 124 |
|
131 | 125 | public static Stream<Arguments> streams() { |
|
0 commit comments