diff --git a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSyncAdapter.kt b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSyncAdapter.kt index 2d53a6a..967b17a 100644 --- a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSyncAdapter.kt +++ b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSyncAdapter.kt @@ -10,8 +10,8 @@ import com.quran.shared.syncengine.conflict.ConflictResolver import com.quran.shared.syncengine.conflict.ConflictDetectionResult import com.quran.shared.syncengine.conflict.ResourceConflict import com.quran.shared.syncengine.model.SyncBookmark -import com.quran.shared.syncengine.preprocessing.LocalMutationsPreprocessor -import com.quran.shared.syncengine.preprocessing.RemoteMutationsPreprocessor +import com.quran.shared.syncengine.preprocessing.BookmarksLocalMutationsPreprocessor +import com.quran.shared.syncengine.preprocessing.BookmarksRemoteMutationsPreprocessor import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.contentOrNull @@ -115,14 +115,14 @@ internal class BookmarksSyncAdapter( private fun preprocessLocalMutations( mutations: List> ): List> { - val preprocessor = LocalMutationsPreprocessor() + val preprocessor = BookmarksLocalMutationsPreprocessor() return preprocessor.preprocess(mutations) } private suspend fun preprocessRemoteMutations( mutations: List> ): List> { - val preprocessor = RemoteMutationsPreprocessor { remoteIds -> + val preprocessor = BookmarksRemoteMutationsPreprocessor { remoteIds -> configurations.localDataFetcher.checkLocalExistence(remoteIds) } return preprocessor.preprocess(mutations) diff --git a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSynchronizationExecutor.kt b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSynchronizationExecutor.kt index d313388..dd64719 100644 --- a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSynchronizationExecutor.kt +++ b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/BookmarksSynchronizationExecutor.kt @@ -9,8 +9,8 @@ import com.quran.shared.syncengine.conflict.ConflictResolutionResult import com.quran.shared.syncengine.conflict.ConflictResolver import com.quran.shared.syncengine.conflict.ResourceConflict import com.quran.shared.syncengine.model.SyncBookmark -import com.quran.shared.syncengine.preprocessing.LocalMutationsPreprocessor -import com.quran.shared.syncengine.preprocessing.RemoteMutationsPreprocessor +import com.quran.shared.syncengine.preprocessing.BookmarksLocalMutationsPreprocessor +import com.quran.shared.syncengine.preprocessing.BookmarksRemoteMutationsPreprocessor /** * Pure business logic executor for bookmark synchronization operations. @@ -103,7 +103,7 @@ class BookmarksSynchronizationExecutor { private fun preprocessLocalMutations( localMutations: List> ): List> { - val preprocessor = LocalMutationsPreprocessor() + val preprocessor = BookmarksLocalMutationsPreprocessor() return preprocessor.preprocess(localMutations) } @@ -111,7 +111,7 @@ class BookmarksSynchronizationExecutor { remoteMutations: List>, checkLocalExistence: suspend (List) -> Map ): List> { - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) return preprocessor.preprocess(remoteMutations) } diff --git a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/SynchronizationClient.kt b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/SynchronizationClient.kt index 3146bf2..00f65cf 100644 --- a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/SynchronizationClient.kt +++ b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/SynchronizationClient.kt @@ -89,7 +89,7 @@ object SynchronizationClientBuilder { notesConfigurations: NotesSynchronizationConfigurations? = null, httpClient: HttpClient? = null ): SynchronizationClient { - val adapters = buildList { + val adapters = buildList { add(BookmarksSyncAdapter(bookmarksConfigurations)) collectionsConfigurations?.let { add(CollectionsSyncAdapter(it)) } collectionBookmarksConfigurations?.let { add(CollectionBookmarksSyncAdapter(it)) } diff --git a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/LocalMutationsPreprocessor.kt b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksLocalMutationsPreprocessor.kt similarity index 99% rename from syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/LocalMutationsPreprocessor.kt rename to syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksLocalMutationsPreprocessor.kt index 1cff107..96e3ff8 100644 --- a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/LocalMutationsPreprocessor.kt +++ b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksLocalMutationsPreprocessor.kt @@ -6,7 +6,7 @@ import com.quran.shared.syncengine.model.SyncBookmark import com.quran.shared.syncengine.model.SyncBookmarkKey import com.quran.shared.syncengine.model.conflictKey -class LocalMutationsPreprocessor { +class BookmarksLocalMutationsPreprocessor { /** * Preprocesses local mutations and throws an error if illogical scenarios are detected. diff --git a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/RemoteMutationsPreprocessor.kt b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksRemoteMutationsPreprocessor.kt similarity index 97% rename from syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/RemoteMutationsPreprocessor.kt rename to syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksRemoteMutationsPreprocessor.kt index 694a85c..e448625 100644 --- a/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/RemoteMutationsPreprocessor.kt +++ b/syncengine/src/commonMain/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksRemoteMutationsPreprocessor.kt @@ -4,7 +4,7 @@ import com.quran.shared.mutations.Mutation import com.quran.shared.mutations.RemoteModelMutation import com.quran.shared.syncengine.model.SyncBookmark -class RemoteMutationsPreprocessor( +class BookmarksRemoteMutationsPreprocessor( private val checkLocalExistence: suspend (List) -> Map ) { diff --git a/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/LocalMutationsPreprocessorTest.kt b/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksLocalMutationsPreprocessorTest.kt similarity index 99% rename from syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/LocalMutationsPreprocessorTest.kt rename to syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksLocalMutationsPreprocessorTest.kt index f971102..79595cf 100644 --- a/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/LocalMutationsPreprocessorTest.kt +++ b/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksLocalMutationsPreprocessorTest.kt @@ -11,9 +11,9 @@ import kotlin.test.assertFailsWith import kotlin.test.assertTrue import kotlin.time.Instant -class LocalMutationsPreprocessorTest { +class BookmarksLocalMutationsPreprocessorTest { - private val preprocessor = LocalMutationsPreprocessor() + private val preprocessor = BookmarksLocalMutationsPreprocessor() @Test fun `should return empty list when no mutations provided`() { diff --git a/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/RemoteMutationsPreprocessorTest.kt b/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksRemoteMutationsPreprocessorTest.kt similarity index 94% rename from syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/RemoteMutationsPreprocessorTest.kt rename to syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksRemoteMutationsPreprocessorTest.kt index a406c63..b8be577 100644 --- a/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/RemoteMutationsPreprocessorTest.kt +++ b/syncengine/src/commonTest/kotlin/com/quran/shared/syncengine/preprocessing/BookmarksRemoteMutationsPreprocessorTest.kt @@ -11,13 +11,13 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.time.Instant -class RemoteMutationsPreprocessorTest { +class BookmarksRemoteMutationsPreprocessorTest { @Test fun `test preprocess with empty mutations list`() = runTest { // Arrange val checkLocalExistence = createMockExistenceChecker(emptySet()) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = emptyList>() // Act @@ -31,7 +31,7 @@ class RemoteMutationsPreprocessorTest { fun `test preprocess with only CREATED mutations`() = runTest { // Arrange val checkLocalExistence = createMockExistenceChecker(emptySet()) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("new-1", 10, Instant.fromEpochMilliseconds(1000)), @@ -59,7 +59,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("existing-1", 10, Instant.fromEpochMilliseconds(1000)), @@ -86,7 +86,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("existing-1", 10, Instant.fromEpochMilliseconds(1000)), @@ -118,7 +118,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1", "existing-2") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("existing-1", 10, Instant.fromEpochMilliseconds(1000)), @@ -150,7 +150,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("new-1", 10, Instant.fromEpochMilliseconds(1000)), @@ -178,7 +178,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1", "existing-2") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( // CREATED mutations (should be kept) RemoteModelMutation( @@ -236,7 +236,7 @@ class RemoteMutationsPreprocessorTest { fun `test preprocess when local data fetcher returns empty existence map`() = runTest { // Arrange val checkLocalExistence = createMockExistenceChecker(emptySet()) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("any-id", 10, Instant.fromEpochMilliseconds(1000)), @@ -264,7 +264,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1", "existing-2") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) val remoteMutations = listOf( RemoteModelMutation( model = PageBookmark("existing-1", 10, Instant.fromEpochMilliseconds(1000)), @@ -303,7 +303,7 @@ class RemoteMutationsPreprocessorTest { // Arrange val existingRemoteIDs = setOf("existing-1", "existing-3") val checkLocalExistence = createMockExistenceChecker(existingRemoteIDs) - val preprocessor = RemoteMutationsPreprocessor(checkLocalExistence) + val preprocessor = BookmarksRemoteMutationsPreprocessor(checkLocalExistence) // Create mutations in a specific order val remoteMutations = listOf(