From 63bc50b39ba590745b394eed37d4be2a804be23d Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Tue, 7 Jan 2025 12:45:56 +0100 Subject: [PATCH] Commit with unresolved merge conflicts --- .../CustomServerConfigRepositoryTest.kt | 89 +++++++++++++++++++ .../ServerConfigRepositoryTest.kt | 46 ++++++++++ .../server/UpdateApiVersionUseCaseTest.kt | 51 +++++++++++ .../daokaliumdb/ServerConfigurationDAO.kt | 6 ++ .../daokaliumdb/ServerConfigurationDAOTest.kt | 11 +++ 5 files changed, 203 insertions(+) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/CustomServerConfigRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/CustomServerConfigRepositoryTest.kt index 3737f9b8900..fc5306dd614 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/CustomServerConfigRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/CustomServerConfigRepositoryTest.kt @@ -71,6 +71,7 @@ class CustomServerConfigRepositoryTest { .storeConfig(arrangement.expectedServerConfig.links, arrangement.expectedServerConfig.metaData) .shouldSucceed { assertEquals(arrangement.expectedServerConfig, it) } +<<<<<<< HEAD coVerify { arrangement.serverConfigurationDAO.configByLinks(any()) }.wasInvoked(exactly = once) @@ -86,6 +87,28 @@ class CustomServerConfigRepositoryTest { verify { arrangement.serverConfigurationDAO.configById(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::configByLinks) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::insert) + .with(any()) + .wasNotInvoked() + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::updateServerMetaData) + .with(any(), any(), any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::setFederationToTrue) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .function(arrangement.serverConfigurationDAO::configById) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @Test @@ -99,6 +122,7 @@ class CustomServerConfigRepositoryTest { .storeConfig(expected.links, expected.metaData) .shouldSucceed { assertEquals(it, expected) } +<<<<<<< HEAD coVerify { arrangement.serverConfigurationDAO.configByLinks(any()) }.wasInvoked(exactly = once) @@ -114,6 +138,28 @@ class CustomServerConfigRepositoryTest { verify { arrangement.serverConfigurationDAO.configById(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::configByLinks) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::insert) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::updateServerMetaData) + .with(any(), any(), any()) + .wasNotInvoked() + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::setFederationToTrue) + .with(any()) + .wasNotInvoked() + verify(arrangement.serverConfigurationDAO) + .function(arrangement.serverConfigurationDAO::configById) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @Test @@ -135,6 +181,7 @@ class CustomServerConfigRepositoryTest { .storeConfig(expectedServerConfig.links, expectedVersionInfo) .shouldSucceed { assertEquals(it, expectedServerConfig) } +<<<<<<< HEAD verify { arrangement.backendMetaDataUtil.calculateApiVersion(any(), any(), any(), any()) }.wasInvoked(exactly = once) @@ -153,6 +200,32 @@ class CustomServerConfigRepositoryTest { verify { arrangement.serverConfigurationDAO.configById(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.backendMetaDataUtil) + .function(arrangement.backendMetaDataUtil::calculateApiVersion) + .with(any(), any(), any(), any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::configByLinks) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::insert) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::updateServerMetaData) + .with(any(), any(), any()) + .wasNotInvoked() + verify(arrangement.serverConfigurationDAO) + .suspendFunction(arrangement.serverConfigurationDAO::setFederationToTrue) + .with(any()) + .wasNotInvoked() + verify(arrangement.serverConfigurationDAO) + .function(arrangement.serverConfigurationDAO::configById) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } private class Arrangement { @@ -161,19 +234,31 @@ class CustomServerConfigRepositoryTest { val SERVER_CONFIG = newServerConfig(1) @Mock +<<<<<<< HEAD val serverConfigApi = mock(ServerConfigApi::class) +======= + val serverConfigApi = mock(classOf()) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) var developmentApiEnabled by Delegates.notNull() @Mock +<<<<<<< HEAD val serverConfigurationDAO = mock(ServerConfigurationDAO::class) +======= + val serverConfigurationDAO = mock(classOf()) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) init { developmentApiEnabled = false } @Mock +<<<<<<< HEAD val backendMetaDataUtil = mock(BackendMetaDataUtil::class) +======= + val backendMetaDataUtil = mock(classOf()) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) private var customServerConfigRepository: CustomServerConfigRepository = CustomServerConfigDataSource(serverConfigApi, developmentApiEnabled, serverConfigurationDAO, backendMetaDataUtil) @@ -186,6 +271,10 @@ class CustomServerConfigRepositoryTest { domain = serverConfigEntity.metaData.domain ) ) +<<<<<<< HEAD +======= + +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) suspend fun withConfigForNewRequest(serverConfigEntity: ServerConfigEntity): Arrangement { every { diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/ServerConfigRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/ServerConfigRepositoryTest.kt index 8f2e1416856..db91d96e2fb 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/ServerConfigRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/configuration/ServerConfigRepositoryTest.kt @@ -124,6 +124,7 @@ class ServerConfigRepositoryTest { .storeConfig(arrangement.expectedServerConfig.links, arrangement.expectedServerConfig.metaData) .shouldSucceed { assertEquals(arrangement.expectedServerConfig, it) } +<<<<<<< HEAD coVerify { arrangement.serverConfigDAO.configByLinks(any()) }.wasInvoked(exactly = once) @@ -139,6 +140,28 @@ class ServerConfigRepositoryTest { verify { arrangement.serverConfigDAO.configById(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::configByLinks) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::insert) + .with(any()) + .wasNotInvoked() + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::updateServerMetaData) + .with(any(), any(), any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::setFederationToTrue) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigDAO) + .function(arrangement.serverConfigDAO::configById) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @Test @@ -152,6 +175,7 @@ class ServerConfigRepositoryTest { .storeConfig(expected.links, expected.metaData) .shouldSucceed { assertEquals(it, expected) } +<<<<<<< HEAD coVerify { arrangement.serverConfigDAO.configByLinks(any()) }.wasInvoked(exactly = once) @@ -167,6 +191,28 @@ class ServerConfigRepositoryTest { verify { arrangement.serverConfigDAO.configById(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::configByLinks) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::insert) + .with(any()) + .wasInvoked(exactly = once) + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::updateServerMetaData) + .with(any(), any(), any()) + .wasNotInvoked() + verify(arrangement.serverConfigDAO) + .suspendFunction(arrangement.serverConfigDAO::setFederationToTrue) + .with(any()) + .wasNotInvoked() + verify(arrangement.serverConfigDAO) + .function(arrangement.serverConfigDAO::configById) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } private class Arrangement(private val dispatcher: KaliumDispatcher) { diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/server/UpdateApiVersionUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/server/UpdateApiVersionUseCaseTest.kt index 3401f58963a..aa4b2a3e69a 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/server/UpdateApiVersionUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/server/UpdateApiVersionUseCaseTest.kt @@ -87,9 +87,17 @@ class UpdateApiVersionUseCaseTest { arrangement.tokenStorage.proxyCredentials(any()) }.wasNotInvoked() +<<<<<<< HEAD coVerify { arrangement.serverConfigRepository1.updateConfigMetaData(eq(serverConfig1)) }.wasInvoked(exactly = once) +======= + + verify(arrangement.serverConfigRepository1) + .suspendFunction(arrangement.serverConfigRepository1::updateConfigMetaData) + .with(eq(serverConfig1)) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @Test @@ -121,9 +129,17 @@ class UpdateApiVersionUseCaseTest { arrangement.tokenStorage.proxyCredentials(any()) }.wasNotInvoked() +<<<<<<< HEAD coVerify { arrangement.serverConfigRepository1.updateConfigMetaData(any()) }.wasInvoked(exactly = once) +======= + + verify(arrangement.serverConfigRepository1) + .suspendFunction(arrangement.serverConfigRepository1::updateConfigMetaData) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @Test @@ -157,9 +173,16 @@ class UpdateApiVersionUseCaseTest { arrangement.tokenStorage.proxyCredentials(any()) }.wasInvoked(exactly = once) +<<<<<<< HEAD coVerify { arrangement.serverConfigRepository1.updateConfigMetaData(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.serverConfigRepository1) + .suspendFunction(arrangement.serverConfigRepository1::updateConfigMetaData) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @Test @@ -207,6 +230,7 @@ class UpdateApiVersionUseCaseTest { arrangement.tokenStorage.proxyCredentials(eq(userId1.toDao())) }.wasNotInvoked() +<<<<<<< HEAD coVerify { arrangement.serverConfigRepository1.updateConfigMetaData(any()) }.wasInvoked(exactly = once) @@ -214,6 +238,17 @@ class UpdateApiVersionUseCaseTest { coVerify { arrangement.serverConfigRepository2.updateConfigMetaData(any()) }.wasInvoked(exactly = once) +======= + verify(arrangement.serverConfigRepository1) + .suspendFunction(arrangement.serverConfigRepository1::updateConfigMetaData) + .with(any()) + .wasInvoked(exactly = once) + + verify(arrangement.serverConfigRepository2) + .suspendFunction(arrangement.serverConfigRepository2::updateConfigMetaData) + .with(any()) + .wasInvoked(exactly = once) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } @@ -249,17 +284,33 @@ class UpdateApiVersionUseCaseTest { }.returns(result) } +<<<<<<< HEAD suspend fun withUpdateConfigMetaData( +======= + fun withUpdateConfigMetaData( +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) serverConfig: ServerConfig, result: Either ) { when (serverConfig.id) { +<<<<<<< HEAD serverConfig1.id -> coEvery { serverConfigRepository1.updateConfigMetaData(any()) } .returns(result) serverConfig2.id -> coEvery { serverConfigRepository2.updateConfigMetaData(any()) } .returns(result) +======= + serverConfig1.id -> given(serverConfigRepository1) + .suspendFunction(serverConfigRepository1::updateConfigMetaData) + .whenInvokedWith(any()) + .then { result } + + serverConfig2.id -> given(serverConfigRepository2) + .suspendFunction(serverConfigRepository2::updateConfigMetaData) + .whenInvokedWith(any()) + .then { result } +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) else -> throw IllegalArgumentException("Unexpected server config: $serverConfig") } diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAO.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAO.kt index 00b56040372..03ddf62e149 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAO.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAO.kt @@ -126,7 +126,10 @@ interface ServerConfigurationDAO { suspend fun allConfig(): List fun configById(id: String): ServerConfigEntity? suspend fun configByLinks(links: ServerConfigEntity.Links): ServerConfigEntity? +<<<<<<< HEAD suspend fun getCommonApiVersion(domain: String): Int +======= +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) suspend fun updateServerMetaData(id: String, federation: Boolean, commonApiVersion: Int) suspend fun updateApiVersionAndDomain(id: String, domain: String, commonApiVersion: Int) suspend fun configForUser(userId: UserIDEntity): ServerConfigEntity? @@ -217,10 +220,13 @@ internal class ServerConfigurationDAOImpl internal constructor( withContext(queriesContext) { queries.updateServerMetaData(federation, commonApiVersion, id) } +<<<<<<< HEAD } override suspend fun getCommonApiVersion(domain: String): Int = withContext(queriesContext) { queries.getCommonApiVersionByDomain(domain).executeAsOne() +======= +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } override suspend fun updateApiVersionAndDomain(id: String, domain: String, commonApiVersion: Int) = diff --git a/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAOTest.kt b/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAOTest.kt index befaae85ff9..c8110adf0df 100644 --- a/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAOTest.kt +++ b/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/daokaliumdb/ServerConfigurationDAOTest.kt @@ -166,15 +166,26 @@ class ServerConfigurationDAOTest : GlobalDBBaseTest() { val expected = oldConfig.copy(metaData = newVersion) insertConfig(oldConfig) +<<<<<<< HEAD globalDatabaseBuilder.serverConfigurationDAO.updateServerMetaData( +======= + db.serverConfigurationDAO.updateServerMetaData( +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) id = oldConfig.id, federation = true, commonApiVersion = 2 ) +<<<<<<< HEAD globalDatabaseBuilder.serverConfigurationDAO.configById(oldConfig.id) .also { actual -> assertEquals(expected.metaData.federation, actual!!.metaData.federation) assertEquals(expected.metaData.apiVersion, actual!!.metaData.apiVersion) +======= + db.serverConfigurationDAO.configById(oldConfig.id) + .also { actual -> + assertEquals(expected.metaData.federation, actual!!.metaData.federation) + assertEquals(expected.metaData.apiVersion, actual.metaData.apiVersion) +>>>>>>> f8e4329102 (fix: update federation flag when fetching server config [WPB-14728] (#3143) (#3189)) } }