From fe771a37c2897cf7586a321dc41145ed1657eea6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 22 May 2024 15:26:01 +0200 Subject: [PATCH] isCalledExactly(1) -> isCalledOnce() --- .../AcceptDeclineInvitePresenterTest.kt | 12 ++--- .../impl/bugreport/BugReportPresenterTest.kt | 2 +- .../impl/room/join/DefaultJoinRoomTest.kt | 12 ++--- .../push/impl/DefaultPushServiceTest.kt | 12 ++--- .../push/impl/DefaultPusherSubscriberTest.kt | 44 +++++++++---------- .../firebase/FirebasePushProviderTest.kt | 8 ++-- .../unifiedpush/UnifiedPushProviderTest.kt | 36 +++++++-------- 7 files changed, 61 insertions(+), 65 deletions(-) diff --git a/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt b/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt index 247df956e6..fd92f9259c 100644 --- a/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt +++ b/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt @@ -192,9 +192,9 @@ class AcceptDeclineInvitePresenterTest { cancelAndConsumeRemainingEvents() } assert(joinRoomFailure) - .isCalledExactly(1) - .withSequence( - listOf(value(A_ROOM_ID), value(emptyList()), value(JoinedRoom.Trigger.Invite)) + .isCalledOnce() + .with( + value(A_ROOM_ID), value(emptyList()), value(JoinedRoom.Trigger.Invite) ) } @@ -221,9 +221,9 @@ class AcceptDeclineInvitePresenterTest { cancelAndConsumeRemainingEvents() } assert(joinRoomSuccess) - .isCalledExactly(1) - .withSequence( - listOf(value(A_ROOM_ID), value(emptyList()), value(JoinedRoom.Trigger.Invite)) + .isCalledOnce() + .with( + value(A_ROOM_ID), value(emptyList()), value(JoinedRoom.Trigger.Invite) ) } diff --git a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt index e0c033afc7..69617f30f8 100644 --- a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt +++ b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt @@ -136,7 +136,7 @@ class BugReportPresenterTest { initialState.eventSink.invoke(BugReportEvents.ResetAll) val resetState = awaitItem() assertThat(resetState.hasCrashLogs).isFalse() - logFilesRemoverLambda.assertions().isCalledExactly(1) + logFilesRemoverLambda.assertions().isCalledOnce() // TODO Make it live assertThat(resetState.screenshotUri).isNull() } } diff --git a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt index 8bbdf47e21..b728d21b3d 100644 --- a/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt +++ b/libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/join/DefaultJoinRoomTest.kt @@ -57,9 +57,9 @@ class DefaultJoinRoomTest { .isNeverCalled() joinRoomLambda .assertions() - .isCalledExactly(1) - .withSequence( - listOf(value(A_ROOM_ID)) + .isCalledOnce() + .with( + value(A_ROOM_ID) ) assertThat(analyticsService.capturedEvents).containsExactly( roomResult.toAnalyticsJoinedRoom(aTrigger) @@ -88,9 +88,9 @@ class DefaultJoinRoomTest { sut.invoke(A_ROOM_ID, A_SERVER_LIST, aTrigger) joinRoomByIdOrAliasLambda .assertions() - .isCalledExactly(1) - .withSequence( - listOf(value(A_ROOM_ID), value(A_SERVER_LIST)) + .isCalledOnce() + .with( + value(A_ROOM_ID), value(A_SERVER_LIST) ) joinRoomLambda .assertions() diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPushServiceTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPushServiceTest.kt index 4f959a6cfc..3268e51a16 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPushServiceTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPushServiceTest.kt @@ -70,8 +70,8 @@ class DefaultPushServiceTest { ) assertThat(defaultPushService.testPush()).isTrue() testPushResult.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(aConfig))) + .isCalledOnce() + .with(value(aConfig)) } @Test @@ -177,11 +177,11 @@ class DefaultPushServiceTest { assertThat(result.isSuccess).isTrue() assertThat(userPushStore.getPushProviderName()).isEqualTo(aPushProvider.name) unregisterLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(client))) + .isCalledOnce() + .with(value(client)) registerLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(client), value(aDistributor))) + .isCalledOnce() + .with(value(client), value(aDistributor)) } @Test diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPusherSubscriberTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPusherSubscriberTest.kt index e6fd39273e..5cb53071e2 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPusherSubscriberTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/DefaultPusherSubscriberTest.kt @@ -99,21 +99,19 @@ class DefaultPusherSubscriberTest { ) assertThat(result).isEqualTo(registerResult) setHttpPusherResult.assertions() - .isCalledExactly(1) - .withSequence( - listOf( - value( - SetHttpPusherData( - pushKey = "aPushKey", - appId = PushConfig.PUSHER_APP_ID, - url = "aGateway", - appDisplayName = "MyApp", - deviceDisplayName = "MyDevice", - profileTag = DEFAULT_PUSHER_FILE_TAG + "_", - lang = "en", - defaultPayload = "{\"cs\":\"$A_SECRET\"}", - ), - ) + .isCalledOnce() + .with( + value( + SetHttpPusherData( + pushKey = "aPushKey", + appId = PushConfig.PUSHER_APP_ID, + url = "aGateway", + appDisplayName = "MyApp", + deviceDisplayName = "MyDevice", + profileTag = DEFAULT_PUSHER_FILE_TAG + "_", + lang = "en", + defaultPayload = "{\"cs\":\"$A_SECRET\"}", + ), ) ) assertThat(userPushStore.getCurrentRegisteredPushKey()).isEqualTo( @@ -167,15 +165,13 @@ class DefaultPusherSubscriberTest { ) assertThat(result).isEqualTo(unregisterResult) unsetHttpPusherResult.assertions() - .isCalledExactly(1) - .withSequence( - listOf( - value( - UnsetHttpPusherData( - pushKey = "aPushKey", - appId = PushConfig.PUSHER_APP_ID, - ), - ) + .isCalledOnce() + .with( + value( + UnsetHttpPusherData( + pushKey = "aPushKey", + appId = PushConfig.PUSHER_APP_ID, + ), ) ) assertThat(userPushStore.getCurrentRegisteredPushKey()).isEqualTo( diff --git a/libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/FirebasePushProviderTest.kt b/libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/FirebasePushProviderTest.kt index 4243db2716..3c82682767 100644 --- a/libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/FirebasePushProviderTest.kt +++ b/libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/FirebasePushProviderTest.kt @@ -82,8 +82,8 @@ class FirebasePushProviderTest { val result = firebasePushProvider.registerWith(matrixClient, Distributor("value", "Name")) assertThat(result).isEqualTo(Result.success(Unit)) registerPusherResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(matrixClient), value("aToken"), value(FirebaseConfig.PUSHER_HTTP_URL))) + .isCalledOnce() + .with(value(matrixClient), value("aToken"), value(FirebaseConfig.PUSHER_HTTP_URL)) } @Test @@ -129,8 +129,8 @@ class FirebasePushProviderTest { val result = firebasePushProvider.unregister(matrixClient) assertThat(result).isEqualTo(Result.success(Unit)) unregisterPusherResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(matrixClient), value("aToken"), value(FirebaseConfig.PUSHER_HTTP_URL))) + .isCalledOnce() + .with(value(matrixClient), value("aToken"), value(FirebaseConfig.PUSHER_HTTP_URL)) } @Test diff --git a/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/UnifiedPushProviderTest.kt b/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/UnifiedPushProviderTest.kt index 7ee626d15b..826f08a1b0 100644 --- a/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/UnifiedPushProviderTest.kt +++ b/libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/UnifiedPushProviderTest.kt @@ -92,14 +92,14 @@ class UnifiedPushProviderTest { val result = unifiedPushProvider.registerWith(FakeMatrixClient(), Distributor("value", "Name")) assertThat(result).isEqualTo(Result.success(Unit)) getSecretForUserResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(A_SESSION_ID))) + .isCalledOnce() + .with(value(A_SESSION_ID)) executeLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(Distributor("value", "Name")), value(A_SECRET))) + .isCalledOnce() + .with(value(Distributor("value", "Name")), value(A_SECRET)) setDistributorValueResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(A_SESSION_ID), value("value"))) + .isCalledOnce() + .with(value(A_SESSION_ID), value("value")) } @Test @@ -121,11 +121,11 @@ class UnifiedPushProviderTest { val result = unifiedPushProvider.registerWith(FakeMatrixClient(), Distributor("value", "Name")) assertThat(result).isEqualTo(Result.failure(AN_EXCEPTION)) getSecretForUserResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(A_SESSION_ID))) + .isCalledOnce() + .with(value(A_SESSION_ID)) executeLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(Distributor("value", "Name")), value(A_SECRET))) + .isCalledOnce() + .with(value(Distributor("value", "Name")), value(A_SECRET)) } @Test @@ -144,11 +144,11 @@ class UnifiedPushProviderTest { val result = unifiedPushProvider.unregister(matrixClient) assertThat(result).isEqualTo(Result.success(Unit)) getSecretForUserResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(A_SESSION_ID))) + .isCalledOnce() + .with(value(A_SESSION_ID)) executeLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(matrixClient), value(A_SECRET))) + .isCalledOnce() + .with(value(matrixClient), value(A_SECRET)) } @Test @@ -167,11 +167,11 @@ class UnifiedPushProviderTest { val result = unifiedPushProvider.unregister(matrixClient) assertThat(result).isEqualTo(Result.failure(AN_EXCEPTION)) getSecretForUserResultLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(A_SESSION_ID))) + .isCalledOnce() + .with(value(A_SESSION_ID)) executeLambda.assertions() - .isCalledExactly(1) - .withSequence(listOf(value(matrixClient), value(A_SECRET))) + .isCalledOnce() + .with(value(matrixClient), value(A_SECRET)) } @Test