|
113 | 113 |
|
114 | 114 | import org.mockito.ArgumentCaptor; |
115 | 115 | import org.mockito.ArgumentMatchers; |
| 116 | +import org.mockito.Mockito; |
116 | 117 | import org.reactivestreams.Subscriber; |
117 | 118 | import org.reactivestreams.Subscription; |
118 | 119 |
|
@@ -782,7 +783,8 @@ public void testExecuteSingleUploadIfEtagMatchesPreconditionFailed() throws IOEx |
782 | 783 | when(client.putObject(any(PutObjectRequest.class), any(RequestBody.class))).thenThrow(preconditionFailedException); |
783 | 784 |
|
784 | 785 | final AtomicReference<Exception> capturedException = new AtomicReference<>(); |
785 | | - ActionListener<String> etagListener = ActionListener.wrap(r -> fail("Should have failed"), capturedException::set); |
| 786 | + ActionListener<String> realListener = ActionListener.wrap(r -> fail("Should have failed"), capturedException::set); |
| 787 | + ActionListener<String> etagListener = Mockito.spy(realListener); |
786 | 788 |
|
787 | 789 | final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[blobSize]); |
788 | 790 | blobContainer.executeSingleUploadIfEtagMatches(blobStore, blobName, inputStream, blobSize, metadata, eTag, etagListener); |
@@ -971,7 +973,8 @@ public void testExecuteSingleUploadIfEtagMatchesSdkException() throws IOExceptio |
971 | 973 | when(client.putObject(any(PutObjectRequest.class), any(RequestBody.class))).thenThrow(sdkException); |
972 | 974 |
|
973 | 975 | final AtomicReference<Exception> capturedException = new AtomicReference<>(); |
974 | | - ActionListener<String> etagListener = ActionListener.wrap(r -> fail("Should have failed for SdkException"), capturedException::set); |
| 976 | + ActionListener<String> realListener = ActionListener.wrap(r -> fail("Should have failed for SdkException"), capturedException::set); |
| 977 | + ActionListener<String> etagListener = Mockito.spy(realListener); |
975 | 978 |
|
976 | 979 | final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[blobSize]); |
977 | 980 | blobContainer.executeSingleUploadIfEtagMatches(blobStore, blobName, inputStream, blobSize, metadata, eTag, etagListener); |
@@ -1067,20 +1070,14 @@ public void testExecuteSingleUploadIfEtagMatchesNullOrEmptyInput() throws IOExce |
1067 | 1070 | verify(mockListenerCase1, never()).onFailure(any()); |
1068 | 1071 | verify(clientReference1).close(); |
1069 | 1072 |
|
1070 | | - final StatsMetricPublisher metricPublisher2 = mock(StatsMetricPublisher.class); |
1071 | | - final software.amazon.awssdk.metrics.MetricPublisher awsMetricPublisher2 = mock( |
1072 | | - software.amazon.awssdk.metrics.MetricPublisher.class |
1073 | | - ); |
1074 | | - when(metricPublisher2.putObjectMetricPublisher).thenReturn(awsMetricPublisher2); |
1075 | | - |
1076 | 1073 | final ByteArrayInputStream inputStreamCase2 = new ByteArrayInputStream(new byte[0]); |
1077 | 1074 | @SuppressWarnings("unchecked") |
1078 | 1075 | ActionListener<String> mockListenerCase2 = mock(ActionListener.class); |
1079 | 1076 |
|
1080 | 1077 | final S3Client client2 = mock(S3Client.class); |
1081 | 1078 | final AmazonS3Reference clientReference2 = mock(AmazonS3Reference.class); |
1082 | 1079 |
|
1083 | | - when(blobStore.getStatsMetricPublisher()).thenReturn(metricPublisher2); |
| 1080 | + when(blobStore.getStatsMetricPublisher()).thenReturn(new StatsMetricPublisher()); |
1084 | 1081 | when(blobStore.clientReference()).thenReturn(clientReference2); |
1085 | 1082 | when(clientReference2.get()).thenReturn(client2); |
1086 | 1083 | when(client2.putObject(any(PutObjectRequest.class), any(RequestBody.class))).thenReturn( |
|
0 commit comments