3737import static org .junit .Assert .assertNull ;
3838import static org .junit .Assert .assertSame ;
3939import static org .junit .Assert .assertTrue ;
40+ import static org .mockito .ArgumentMatchers .eq ;
4041import static org .mockito .Mockito .any ;
4142import static org .mockito .Mockito .anyInt ;
4243import static org .mockito .Mockito .times ;
@@ -115,7 +116,7 @@ private RetrySettings getDefaultRetrySettings() {
115116
116117 @ Test
117118 public void testSuccess () throws Exception {
118- FailingCallable callable = new FailingCallable (0 , "SUCCESS" , tracer );
119+ FailingCallable callable = new FailingCallable (0 , "request" , " SUCCESS" , tracer );
119120 RetryingExecutorWithContext <String > executor =
120121 getExecutor (getAlgorithm (getDefaultRetrySettings (), 0 , null ));
121122 RetryingFuture <String > future = executor .createFuture (callable , retryingContext );
@@ -124,14 +125,14 @@ public void testSuccess() throws Exception {
124125 assertFutureSuccess (future );
125126 assertEquals (0 , future .getAttemptSettings ().getAttemptCount ());
126127
127- verify (tracer , times (1 )).attemptStarted (0 );
128+ verify (tracer , times (1 )).attemptStarted (eq ( "request" ), eq ( 0 ) );
128129 verify (tracer , times (1 )).attemptSucceeded ();
129130 verifyNoMoreInteractions (tracer );
130131 }
131132
132133 @ Test
133134 public void testSuccessWithFailures () throws Exception {
134- FailingCallable callable = new FailingCallable (5 , "SUCCESS" , tracer );
135+ FailingCallable callable = new FailingCallable (5 , "request" , " SUCCESS" , tracer );
135136 RetryingExecutorWithContext <String > executor =
136137 getExecutor (getAlgorithm (getDefaultRetrySettings (), 0 , null ));
137138 RetryingFuture <String > future = executor .createFuture (callable , retryingContext );
@@ -140,15 +141,15 @@ public void testSuccessWithFailures() throws Exception {
140141 assertFutureSuccess (future );
141142 assertEquals (5 , future .getAttemptSettings ().getAttemptCount ());
142143
143- verify (tracer , times (6 )).attemptStarted (anyInt ());
144+ verify (tracer , times (6 )).attemptStarted (eq ( "request" ), anyInt ());
144145 verify (tracer , times (5 )).attemptFailed (any (Throwable .class ), any (Duration .class ));
145146 verify (tracer , times (1 )).attemptSucceeded ();
146147 verifyNoMoreInteractions (tracer );
147148 }
148149
149150 @ Test
150151 public void testSuccessWithFailuresPeekGetAttempt () throws Exception {
151- FailingCallable callable = new FailingCallable (5 , "SUCCESS" , tracer );
152+ FailingCallable callable = new FailingCallable (5 , "request" , " SUCCESS" , tracer );
152153 RetryingExecutorWithContext <String > executor =
153154 getExecutor (getAlgorithm (getDefaultRetrySettings (), 0 , null ));
154155 RetryingFuture <String > future = executor .createFuture (callable , retryingContext );
@@ -174,7 +175,7 @@ public void testSuccessWithFailuresPeekGetAttempt() throws Exception {
174175
175176 @ Test
176177 public void testMaxRetriesExceeded () throws Exception {
177- FailingCallable callable = new FailingCallable (6 , "FAILURE" , tracer );
178+ FailingCallable callable = new FailingCallable (6 , "request" , " FAILURE" , tracer );
178179 RetryingExecutorWithContext <String > executor =
179180 getExecutor (getAlgorithm (getDefaultRetrySettings (), 0 , null ));
180181 RetryingFuture <String > future = executor .createFuture (callable , retryingContext );
@@ -183,7 +184,7 @@ public void testMaxRetriesExceeded() throws Exception {
183184 assertFutureFail (future , CustomException .class );
184185 assertEquals (5 , future .getAttemptSettings ().getAttemptCount ());
185186
186- verify (tracer , times (6 )).attemptStarted (anyInt ());
187+ verify (tracer , times (6 )).attemptStarted (eq ( "request" ), anyInt ());
187188 verify (tracer , times (5 )).attemptFailed (any (Throwable .class ), any (Duration .class ));
188189 verify (tracer , times (1 )).attemptFailedRetriesExhausted (any (Throwable .class ));
189190 verifyNoMoreInteractions (tracer );
@@ -202,7 +203,7 @@ public void testTotalTimeoutExceeded() throws Exception {
202203 getExecutor (
203204 getAlgorithm (
204205 useContextRetrySettings ? getDefaultRetrySettings () : retrySettings , 0 , null ));
205- FailingCallable callable = new FailingCallable (6 , "FAILURE" , tracer );
206+ FailingCallable callable = new FailingCallable (6 , "request" , " FAILURE" , tracer );
206207 RetryingContext context ;
207208 if (useContextRetrySettings ) {
208209 context = FakeCallContext .createDefault ().withTracer (tracer ).withRetrySettings (retrySettings );
@@ -215,14 +216,14 @@ public void testTotalTimeoutExceeded() throws Exception {
215216 assertFutureFail (future , CustomException .class );
216217 assertTrue (future .getAttemptSettings ().getAttemptCount () < 4 );
217218
218- verify (tracer , times (1 )).attemptStarted (anyInt ());
219+ verify (tracer , times (1 )).attemptStarted (eq ( "request" ), anyInt ());
219220 verify (tracer , times (1 )).attemptFailedRetriesExhausted (any (Throwable .class ));
220221 verifyNoMoreInteractions (tracer );
221222 }
222223
223224 @ Test
224225 public void testCancelOuterFutureBeforeStart () throws Exception {
225- FailingCallable callable = new FailingCallable (4 , "SUCCESS" , tracer );
226+ FailingCallable callable = new FailingCallable (4 , "request" , " SUCCESS" , tracer );
226227
227228 RetrySettings retrySettings =
228229 FAST_RETRY_SETTINGS
@@ -248,7 +249,7 @@ public void testCancelOuterFutureBeforeStart() throws Exception {
248249
249250 @ Test
250251 public void testCancelByRetryingAlgorithm () throws Exception {
251- FailingCallable callable = new FailingCallable (6 , "FAILURE" , tracer );
252+ FailingCallable callable = new FailingCallable (6 , "request" , " FAILURE" , tracer );
252253 RetryingExecutorWithContext <String > executor =
253254 getExecutor (getAlgorithm (getDefaultRetrySettings (), 5 , new CancellationException ()));
254255 RetryingFuture <String > future = executor .createFuture (callable , retryingContext );
@@ -257,7 +258,7 @@ public void testCancelByRetryingAlgorithm() throws Exception {
257258 assertFutureCancel (future );
258259 assertEquals (4 , future .getAttemptSettings ().getAttemptCount ());
259260
260- verify (tracer , times (5 )).attemptStarted (anyInt ());
261+ verify (tracer , times (5 )).attemptStarted (eq ( "request" ), anyInt ());
261262 // Pre-apocalypse failures
262263 verify (tracer , times (4 )).attemptFailed (any (Throwable .class ), any (Duration .class ));
263264 // Apocalypse failure
@@ -267,7 +268,7 @@ public void testCancelByRetryingAlgorithm() throws Exception {
267268
268269 @ Test
269270 public void testUnexpectedExceptionFromRetryAlgorithm () throws Exception {
270- FailingCallable callable = new FailingCallable (6 , "FAILURE" , tracer );
271+ FailingCallable callable = new FailingCallable (6 , "request" , " FAILURE" , tracer );
271272 RetryingExecutorWithContext <String > executor =
272273 getExecutor (getAlgorithm (getDefaultRetrySettings (), 5 , new RuntimeException ()));
273274 RetryingFuture <String > future = executor .createFuture (callable , retryingContext );
@@ -276,7 +277,7 @@ public void testUnexpectedExceptionFromRetryAlgorithm() throws Exception {
276277 assertFutureFail (future , RuntimeException .class );
277278 assertEquals (4 , future .getAttemptSettings ().getAttemptCount ());
278279
279- verify (tracer , times (5 )).attemptStarted (anyInt ());
280+ verify (tracer , times (5 )).attemptStarted (eq ( "request" ), anyInt ());
280281 // Pre-apocalypse failures
281282 verify (tracer , times (4 )).attemptFailed (any (Throwable .class ), any (Duration .class ));
282283 // Apocalypse failure
@@ -302,7 +303,7 @@ public void testPollExceptionByPollAlgorithm() throws Exception {
302303 NanoClock .getDefaultClock ()));
303304
304305 RetryingExecutorWithContext <String > executor = getExecutor (retryAlgorithm );
305- FailingCallable callable = new FailingCallable (6 , "FAILURE" , tracer );
306+ FailingCallable callable = new FailingCallable (6 , "request" , " FAILURE" , tracer );
306307 RetryingContext context ;
307308 if (useContextRetrySettings ) {
308309 context = FakeCallContext .createDefault ().withTracer (tracer ).withRetrySettings (retrySettings );
@@ -315,7 +316,7 @@ public void testPollExceptionByPollAlgorithm() throws Exception {
315316 assertFutureFail (future , PollException .class );
316317 assertTrue (future .getAttemptSettings ().getAttemptCount () < 4 );
317318
318- verify (tracer , times (1 )).attemptStarted (anyInt ());
319+ verify (tracer , times (1 )).attemptStarted (eq ( "request" ), anyInt ());
319320 verify (tracer , times (1 )).attemptPermanentFailure (any (PollException .class ));
320321 verifyNoMoreInteractions (tracer );
321322 }
0 commit comments