-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: more arrangement classes (#1956)
* chore: more arrangement classes * Update logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/ConnectionRepositoryArrangement.kt Co-authored-by: Vitor Hugo Schwaab <vitor@schwaab.dev> * Update logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/ConversationRepositoryArrangement.kt Co-authored-by: Vitor Hugo Schwaab <vitor@schwaab.dev> * Update logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/UserRepositoryArrangement.kt Co-authored-by: Vitor Hugo Schwaab <vitor@schwaab.dev> * Update logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/usecase/PersistMessageUseCaseArrangement.kt Co-authored-by: Vitor Hugo Schwaab <vitor@schwaab.dev> --------- Co-authored-by: Vitor Hugo Schwaab <vitor@schwaab.dev>
- Loading branch information
1 parent
fe7a70e
commit 56387a4
Showing
6 changed files
with
167 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...tlin/com/wire/kalium/logic/util/arrangement/repository/ConnectionRepositoryArrangement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.util.arrangement.repository | ||
|
||
import com.wire.kalium.logic.StorageFailure | ||
import com.wire.kalium.logic.data.connection.ConnectionRepository | ||
import com.wire.kalium.logic.data.conversation.ConversationDetails | ||
import com.wire.kalium.logic.functional.Either | ||
import io.mockative.Mock | ||
import io.mockative.given | ||
import io.mockative.mock | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
internal interface ConnectionRepositoryArrangement { | ||
val connectionRepository: ConnectionRepository | ||
|
||
fun withGetConnections(result: Either<StorageFailure, Flow<List<ConversationDetails>>>) | ||
} | ||
|
||
internal open class ConnectionRepositoryArrangementImpl : ConnectionRepositoryArrangement { | ||
@Mock | ||
override val connectionRepository: ConnectionRepository = mock(ConnectionRepository::class) | ||
|
||
override fun withGetConnections( | ||
result: Either<StorageFailure, Flow<List<ConversationDetails>>>, | ||
) { | ||
given(connectionRepository) | ||
.suspendFunction(connectionRepository::getConnections) | ||
.whenInvoked() | ||
.thenReturn(result) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...in/com/wire/kalium/logic/util/arrangement/repository/ConversationRepositoryArrangement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.util.arrangement.repository | ||
|
||
import com.wire.kalium.logic.data.conversation.ConversationRepository | ||
import io.mockative.Mock | ||
import io.mockative.mock | ||
|
||
internal interface ConversationRepositoryArrangement { | ||
val conversationRepository: ConversationRepository | ||
} | ||
|
||
internal open class ConversationRepositoryArrangementImpl : ConversationRepositoryArrangement { | ||
@Mock | ||
override val conversationRepository: ConversationRepository = mock(ConversationRepository::class) | ||
} |
31 changes: 31 additions & 0 deletions
31
...est/kotlin/com/wire/kalium/logic/util/arrangement/repository/UserRepositoryArrangement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.util.arrangement.repository | ||
|
||
import com.wire.kalium.logic.data.user.UserRepository | ||
import io.mockative.Mock | ||
import io.mockative.mock | ||
|
||
internal interface UserRepositoryArrangement { | ||
val userRepository: UserRepository | ||
} | ||
|
||
internal open class UserRepositoryArrangementImpl : UserRepositoryArrangement { | ||
@Mock | ||
override val userRepository: UserRepository = mock(UserRepository::class) | ||
} |
43 changes: 43 additions & 0 deletions
43
...kotlin/com/wire/kalium/logic/util/arrangement/usecase/PersistMessageUseCaseArrangement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.util.arrangement.usecase | ||
|
||
import com.wire.kalium.logic.CoreFailure | ||
import com.wire.kalium.logic.data.message.PersistMessageUseCase | ||
import com.wire.kalium.logic.functional.Either | ||
import io.mockative.Mock | ||
import io.mockative.any | ||
import io.mockative.given | ||
import io.mockative.mock | ||
|
||
internal interface PersistMessageUseCaseArrangement { | ||
val persistMessageUseCase: PersistMessageUseCase | ||
fun withPersistingMessage(result: Either<CoreFailure, Unit>): PersistMessageUseCaseArrangementImpl | ||
} | ||
|
||
internal open class PersistMessageUseCaseArrangementImpl : PersistMessageUseCaseArrangement { | ||
@Mock | ||
override val persistMessageUseCase: PersistMessageUseCase = mock(PersistMessageUseCase::class) | ||
|
||
override fun withPersistingMessage(result: Either<CoreFailure, Unit>) = apply { | ||
given(persistMessageUseCase) | ||
.suspendFunction(persistMessageUseCase::invoke) | ||
.whenInvokedWith(any()) | ||
.thenReturn(result) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters