88import static org .assertj .core .api .Assertions .assertThat ;
99import static org .awaitility .Awaitility .await ;
1010import static org .mockito .ArgumentMatchers .any ;
11+ import static org .mockito .ArgumentMatchers .eq ;
1112import static org .mockito .Mockito .never ;
1213import static org .mockito .Mockito .spy ;
1314import static org .mockito .Mockito .verify ;
@@ -199,7 +200,8 @@ void onSuccess_withChangesToReport_notifyCallbackOnMessage() {
199200 // Await for onMessage call
200201 await ().atMost (Duration .ofSeconds (5 )).until (() -> callbacks .onMessageCalls .get () == 1 );
201202
202- verify (callbacks ).onMessage (MessageData .builder ().setRemoteConfig (remoteConfig ).build ());
203+ verify (callbacks )
204+ .onMessage (client , MessageData .builder ().setRemoteConfig (remoteConfig ).build ());
203205 }
204206
205207 @ Test
@@ -214,7 +216,7 @@ void onSuccess_withNoChangesToReport_doNotNotifyCallbackOnMessage() {
214216 // Giving some time for the callback to get called
215217 await ().during (Duration .ofSeconds (1 ));
216218
217- verify (callbacks , never ()).onMessage (any ());
219+ verify (callbacks , never ()).onMessage (eq ( client ), any ());
218220 }
219221
220222 @ Test
@@ -257,8 +259,8 @@ void onConnectionSuccessful_notifyCallback() {
257259
258260 await ().atMost (Duration .ofSeconds (5 )).until (() -> callbacks .onConnectCalls .get () == 1 );
259261
260- verify (callbacks ).onConnect ();
261- verify (callbacks , never ()).onConnectFailed (any ());
262+ verify (callbacks ).onConnect (client );
263+ verify (callbacks , never ()).onConnectFailed (eq ( client ), any ());
262264 }
263265
264266 @ Test
@@ -301,8 +303,8 @@ void onFailedResponse_withServerErrorData_notifyCallback() {
301303
302304 await ().atMost (Duration .ofSeconds (5 )).until (() -> callbacks .onErrorResponseCalls .get () == 1 );
303305
304- verify (callbacks ).onErrorResponse (errorResponse );
305- verify (callbacks , never ()).onMessage (any ());
306+ verify (callbacks ).onErrorResponse (client , errorResponse );
307+ verify (callbacks , never ()).onMessage (eq ( client ), any ());
306308 }
307309
308310 @ Test
@@ -312,7 +314,7 @@ void onConnectionFailed_notifyCallback() {
312314
313315 client .onConnectionFailed (throwable );
314316
315- verify (callbacks ).onConnectFailed (throwable );
317+ verify (callbacks ).onConnectFailed (client , throwable );
316318 }
317319
318320 @ Test
@@ -450,22 +452,22 @@ private static class TestCallbacks implements OpampClient.Callbacks {
450452 private final AtomicInteger onMessageCalls = new AtomicInteger ();
451453
452454 @ Override
453- public void onConnect () {
455+ public void onConnect (OpampClient client ) {
454456 onConnectCalls .incrementAndGet ();
455457 }
456458
457459 @ Override
458- public void onConnectFailed (@ Nullable Throwable throwable ) {
460+ public void onConnectFailed (OpampClient client , @ Nullable Throwable throwable ) {
459461 onConnectFailedCalls .incrementAndGet ();
460462 }
461463
462464 @ Override
463- public void onErrorResponse (ServerErrorResponse errorResponse ) {
465+ public void onErrorResponse (OpampClient client , ServerErrorResponse errorResponse ) {
464466 onErrorResponseCalls .incrementAndGet ();
465467 }
466468
467469 @ Override
468- public void onMessage (MessageData messageData ) {
470+ public void onMessage (OpampClient client , MessageData messageData ) {
469471 onMessageCalls .incrementAndGet ();
470472 }
471473 }
0 commit comments