From d2bdbae6c8dad7a1f160396c3129b2f0b40195bb Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sat, 22 Oct 2022 20:47:38 +0200 Subject: [PATCH 1/2] Launching ios APP. --- androidApp/build.gradle.kts | 12 +- .../apps/readerforselfossv2/android/MyApp.kt | 7 +- .../android/fragments/ArticleFragment.kt | 2 + build.gradle.kts | 23 +- gradle.properties | 19 +- iosApp/iosApp.xcodeproj/project.pbxproj | 742 +++++++++--------- iosApp/iosApp/ContentView.swift | 5 +- settings.gradle.kts | 8 + shared/build.gradle.kts | 30 +- .../repository/RepositoryImpl.kt | 9 +- 10 files changed, 437 insertions(+), 420 deletions(-) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 713cc7b..a13deb4 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -58,7 +58,7 @@ android { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } - compileSdk = 31 + compileSdk = 32 buildToolsVersion = "31.0.0" buildFeatures { viewBinding = true @@ -66,7 +66,7 @@ android { defaultConfig { applicationId = "bou.amine.apps.readerforselfossv2.android" minSdk = 21 - targetSdk = 31 + targetSdk = 32 versionCode = versionCodeFromGit() versionName = versionNameFromGit() @@ -79,6 +79,11 @@ android { // tests testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + packagingOptions { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } buildTypes { getByName("release") { isMinifyEnabled = true @@ -98,9 +103,6 @@ android { dimension = "build" } } - kotlinOptions { - jvmTarget = "1.8" - } namespace = "bou.amine.apps.readerforselfossv2.android" } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt index 49c803c..3ca267b 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt @@ -14,6 +14,7 @@ import androidx.lifecycle.ProcessLifecycleOwner import androidx.multidex.MultiDexApplication import androidx.preference.PreferenceManager import bou.amine.apps.readerforselfossv2.DI.networkModule +import bou.amine.apps.readerforselfossv2.android.utils.network.isNetworkAccessible import bou.amine.apps.readerforselfossv2.android.viewmodel.AppViewModel import bou.amine.apps.readerforselfossv2.dao.DriverFactory import bou.amine.apps.readerforselfossv2.dao.ReaderForSelfossDB @@ -28,6 +29,7 @@ import io.github.aakira.napier.DebugAntilog import io.github.aakira.napier.Napier import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import org.kodein.di.* @@ -37,7 +39,7 @@ class MyApp : MultiDexApplication(), DIAware { import(networkModule) bind() with singleton { DriverFactory(applicationContext) } bind() with singleton { ReaderForSelfossDB(driverFactory.createDriver()) } - bind() with singleton { Repository(instance(), instance(), connectivityStatus, instance()) } + bind() with singleton { Repository(instance(), instance(), isConnectionAvailable, instance()) } bind() with singleton { ConnectivityStatus(applicationContext) } bind() with singleton { AppViewModel(repository = instance()) } } @@ -47,6 +49,9 @@ class MyApp : MultiDexApplication(), DIAware { private val connectivityStatus: ConnectivityStatus by instance() private val driverFactory: DriverFactory by instance() + // TODO: handle with the "previous" way + private val isConnectionAvailable: MutableStateFlow = MutableStateFlow(true) + override fun onCreate() { super.onCreate() Napier.base(DebugAntilog()) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt index 4e9ada7..cebefc9 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt @@ -354,6 +354,7 @@ class ArticleFragment : Fragment(), DIAware { binding.webcontent.settings.javaScriptEnabled = false binding.webcontent.webViewClient = object : WebViewClient() { + @Deprecated("Deprecated in Java") override fun shouldOverrideUrlLoading(view: WebView?, url : String): Boolean { if (binding.webcontent.hitTestResult.type != WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { requireContext().startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) @@ -361,6 +362,7 @@ class ArticleFragment : Fragment(), DIAware { return true } + @Deprecated("Deprecated in Java") override fun shouldInterceptRequest(view: WebView?, url: String): WebResourceResponse? { val glideOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL) if (url.lowercase(Locale.US).contains(".jpg") || url.lowercase(Locale.US).contains(".jpeg")) { diff --git a/build.gradle.kts b/build.gradle.kts index 27db859..f4d60ef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,21 +1,19 @@ buildscript { - repositories { - gradlePluginPortal() - google() - mavenCentral() - } dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") - classpath("com.android.tools.build:gradle:7.3.0") - - // sonarquve - classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513") - // SqlDelight classpath("com.squareup.sqldelight:gradle-plugin:1.5.3") } } +plugins { + //trick: for the same plugin versions in all sub-modules + id("com.android.application").version("7.3.1").apply(false) + id("com.android.library").version("7.3.1").apply(false) + kotlin("android").version("1.7.10").apply(false) + kotlin("multiplatform").version("1.7.10").apply(false) + id("org.sonarqube").version("3.4.0.2513").apply(false) +} + apply(plugin = "org.sonarqube") allprojects { @@ -27,6 +25,7 @@ allprojects { } } + tasks.register("clean", Delete::class) { delete(rootProject.buildDir) -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 1503398..900f643 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,14 +11,27 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Tue Mar 22 16:50:00 CET 2022 +#Gradle +org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" + +#Kotlin kotlin.code.style=official -kotlin.mpp.enableCInteropCommonization=true -org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" -kotlin.native.enableDependencyPropagation=false + +#Android android.useAndroidX=true +kotlin.native.enableDependencyPropagation=false +#android.nonTransitiveRClass=true android.enableJetifier=true + + +#MPP +kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.enableGranularSourceSetsMetadata=true + + org.gradle.parallel=true org.gradle.caching=true ignoreGitVersion=false +kotlin.native.cacheKind.iosX64=none pushCache=true + diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index 9909002..279f7f1 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -1,383 +1,383 @@ - // !$*UTF8*$! - { - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { - /* Begin PBXBuildFile section */ -058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; -058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; - 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; - /* End PBXBuildFile section */ +/* Begin PBXBuildFile section */ + 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; + 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; + 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; +/* End PBXBuildFile section */ - /* Begin PBXCopyFilesBuildPhase section */ - 7555FFB4242A642300829871 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; - /* End PBXCopyFilesBuildPhase section */ +/* Begin PBXCopyFilesBuildPhase section */ + 7555FFB4242A642300829871 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ - 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; -058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; - 7555FF7B242A565900829871 /* iosApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - /* End PBXFileReference section */ +/* Begin PBXFileReference section */ + 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; + 7555FF7B242A565900829871 /* iosApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ - /* Begin PBXFrameworksBuildPhase section */ - 7555FF78242A565900829871 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - /* End PBXFrameworksBuildPhase section */ +/* Begin PBXFrameworksBuildPhase section */ + 7555FF78242A565900829871 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ - /* Begin PBXGroup section */ - 058557D7273AAEEB004C7B11 /* Preview Content */ = { - isa = PBXGroup; - children = ( - 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; -}; - 7555FF72242A565900829871 = { - isa = PBXGroup; - children = ( - 7555FF7D242A565900829871 /* iosApp */, - 7555FF7C242A565900829871 /* Products */, - 7555FFB0242A642200829871 /* Frameworks */, - ); - sourceTree = ""; - }; - 7555FF7C242A565900829871 /* Products */ = { - isa = PBXGroup; - children = ( - 7555FF7B242A565900829871 /* iosApp.app */, - ); - name = Products; - sourceTree = ""; - }; - 7555FF7D242A565900829871 /* iosApp */ = { - isa = PBXGroup; - children = ( - 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, - 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iOSApp.swift */, - 058557D7273AAEEB004C7B11 /* Preview Content */, - ); - path = iosApp; - sourceTree = ""; - }; - 7555FFB0242A642200829871 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; - /* End PBXGroup section */ +/* Begin PBXGroup section */ + 058557D7273AAEEB004C7B11 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 7555FF72242A565900829871 = { + isa = PBXGroup; + children = ( + 7555FF7D242A565900829871 /* iosApp */, + 7555FF7C242A565900829871 /* Products */, + 7555FFB0242A642200829871 /* Frameworks */, + ); + sourceTree = ""; + }; + 7555FF7C242A565900829871 /* Products */ = { + isa = PBXGroup; + children = ( + 7555FF7B242A565900829871 /* iosApp.app */, + ); + name = Products; + sourceTree = ""; + }; + 7555FF7D242A565900829871 /* iosApp */ = { + isa = PBXGroup; + children = ( + 058557BA273AAA24004C7B11 /* Assets.xcassets */, + 7555FF82242A565900829871 /* ContentView.swift */, + 7555FF8C242A565B00829871 /* Info.plist */, + 2152FB032600AC8F00CF470E /* iOSApp.swift */, + 058557D7273AAEEB004C7B11 /* Preview Content */, + ); + path = iosApp; + sourceTree = ""; + }; + 7555FFB0242A642200829871 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ - /* Begin PBXNativeTarget section */ - 7555FF7A242A565900829871 /* iosApp */ = { - isa = PBXNativeTarget; - buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; - buildPhases = ( - 7555FFB5242A651A00829871 /* ShellScript */, - 7555FF77242A565900829871 /* Sources */, - 7555FF78242A565900829871 /* Frameworks */, - 7555FF79242A565900829871 /* Resources */, - 7555FFB4242A642300829871 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = iosApp; - productName = iosApp; - productReference = 7555FF7B242A565900829871 /* iosApp.app */; - productType = "com.apple.product-type.application"; - }; - /* End PBXNativeTarget section */ +/* Begin PBXNativeTarget section */ + 7555FF7A242A565900829871 /* iosApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; + buildPhases = ( + 7555FFB5242A651A00829871 /* ShellScript */, + 7555FF77242A565900829871 /* Sources */, + 7555FF78242A565900829871 /* Frameworks */, + 7555FF79242A565900829871 /* Resources */, + 7555FFB4242A642300829871 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = iosApp; + productName = iosApp; + productReference = 7555FF7B242A565900829871 /* iosApp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ - /* Begin PBXProject section */ - 7555FF73242A565900829871 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1130; - LastUpgradeCheck = 1130; - ORGANIZATIONNAME = orgName; - TargetAttributes = { - 7555FF7A242A565900829871 = { - CreatedOnToolsVersion = 11.3.1; - }; - }; - }; - buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 7555FF72242A565900829871; - productRefGroup = 7555FF7C242A565900829871 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 7555FF7A242A565900829871 /* iosApp */, - ); - }; - /* End PBXProject section */ +/* Begin PBXProject section */ + 7555FF73242A565900829871 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1130; + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = orgName; + TargetAttributes = { + 7555FF7A242A565900829871 = { + CreatedOnToolsVersion = 11.3.1; + }; + }; + }; + buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 7555FF72242A565900829871; + productRefGroup = 7555FF7C242A565900829871 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 7555FF7A242A565900829871 /* iosApp */, + ); + }; +/* End PBXProject section */ - /* Begin PBXResourcesBuildPhase section */ - 7555FF79242A565900829871 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, - 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - /* End PBXResourcesBuildPhase section */ +/* Begin PBXResourcesBuildPhase section */ + 7555FF79242A565900829871 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, + 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ - /* Begin PBXShellScriptBuildPhase section */ - 7555FFB5242A651A00829871 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n"; - }; - /* End PBXShellScriptBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 7555FFB5242A651A00829871 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n"; + }; +/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ - 7555FF77242A565900829871 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - /* End PBXSourcesBuildPhase section */ +/* Begin PBXSourcesBuildPhase section */ + 7555FF77242A565900829871 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, + 7555FF83242A565900829871 /* ContentView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ - /* Begin XCBuildConfiguration section */ - 7555FFA3242A565B00829871 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 7555FFA4242A565B00829871 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 7555FFA6242A565B00829871 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - ENABLE_PREVIEWS = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; - INFOPLIST_FILE = iosApp/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - shared, - ); - PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 7555FFA7242A565B00829871 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - ENABLE_PREVIEWS = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; - INFOPLIST_FILE = iosApp/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - shared, - ); - PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - /* End XCBuildConfiguration section */ +/* Begin XCBuildConfiguration section */ + 7555FFA3242A565B00829871 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 7555FFA4242A565B00829871 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 7555FFA6242A565B00829871 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; + INFOPLIST_FILE = iosApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + shared, + ); + PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 7555FFA7242A565B00829871 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; + INFOPLIST_FILE = iosApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + shared, + ); + PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ - /* Begin XCConfigurationList section */ - 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7555FFA3242A565B00829871 /* Debug */, - 7555FFA4242A565B00829871 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7555FFA6242A565B00829871 /* Debug */, - 7555FFA7242A565B00829871 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - /* End XCConfigurationList section */ - }; - rootObject = 7555FF73242A565900829871 /* Project object */; - } \ No newline at end of file +/* Begin XCConfigurationList section */ + 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7555FFA3242A565B00829871 /* Debug */, + 7555FFA4242A565B00829871 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7555FFA6242A565B00829871 /* Debug */, + 7555FFA7242A565B00829871 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 7555FF73242A565900829871 /* Project object */; +} diff --git a/iosApp/iosApp/ContentView.swift b/iosApp/iosApp/ContentView.swift index 2c62f19..f63ace4 100644 --- a/iosApp/iosApp/ContentView.swift +++ b/iosApp/iosApp/ContentView.swift @@ -2,12 +2,9 @@ import SwiftUI import shared struct ContentView: View { - let greet = Greeting().greeting() - - let toto = SelfossApi().getItems() var body: some View { - Text(greet) + Text("ototot") } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 4f3bcd9..749e0ad 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,6 +8,14 @@ pluginManagement { } } +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} + + buildCache { remote { url = uri("http://18.0.0.7:3071/cache/") diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index e80af33..c4020d8 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -18,7 +18,7 @@ kotlin { listOf( iosX64(), iosArm64(), - //iosSimulatorArm64() sure all ios dependencies support this target + iosSimulatorArm64() ).forEach { it.binaries.framework { baseName = "shared" @@ -45,9 +45,6 @@ kotlin { //Logging implementation("io.github.aakira:napier:2.6.1") - // Network information - implementation("com.github.ln-12:multiplatform-connectivity-status:1.3.0") - // Sql implementation(SqlDelight.runtime) } @@ -56,8 +53,9 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("io.mockk:mockk:1.12.0") + // implementation("io.mockk:mockk:1.12.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + } } val androidMain by getting { @@ -76,39 +74,36 @@ kotlin { } val iosX64Main by getting val iosArm64Main by getting - //val iosSimulatorArm64Main by getting + val iosSimulatorArm64Main by getting val iosMain by creating { dependsOn(commonMain) iosX64Main.dependsOn(this) iosArm64Main.dependsOn(this) - //iosSimulatorArm64Main.dependsOn(this) + iosSimulatorArm64Main.dependsOn(this) - // Sql dependencies { implementation(SqlDelight.native) + implementation("io.ktor:ktor-client-ios:2.1.1") } } val iosX64Test by getting val iosArm64Test by getting - //val iosSimulatorArm64Test by getting + val iosSimulatorArm64Test by getting val iosTest by creating { dependsOn(commonTest) iosX64Test.dependsOn(this) iosArm64Test.dependsOn(this) - dependencies { - implementation("io.ktor:ktor-client-ios:2.1.1") - } - //iosSimulatorArm64Test.dependsOn(this) + iosSimulatorArm64Test.dependsOn(this) } } } android { - compileSdk = 31 + compileSdk = 32 sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { minSdk = 21 - targetSdk = 31 + targetSdk = 32 } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -117,10 +112,11 @@ android { namespace = "bou.amine.apps.readerforselfossv2" } + + sqldelight { database("ReaderForSelfossDB") { packageName = "bou.amine.apps.readerforselfossv2.dao" sourceFolders = listOf("sqldelight") } -} - +} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index 2b1a8aa..cf25229 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -6,17 +6,16 @@ import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.rest.SelfossApi import bou.amine.apps.readerforselfossv2.service.AppSettingsService import bou.amine.apps.readerforselfossv2.utils.* -import com.github.ln_12.library.ConnectivityStatus import io.github.aakira.napier.Napier import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -class Repository(private val api: SelfossApi, private val appSettingsService: AppSettingsService, connectivityStatus: ConnectivityStatus, private val db: ReaderForSelfossDB) { +class Repository(private val api: SelfossApi, private val appSettingsService: AppSettingsService, val isConnectionAvailable: MutableStateFlow, private val db: ReaderForSelfossDB) { var items = ArrayList() - val isConnectionAvailable = connectivityStatus.isNetworkConnected var connectionMonitored = false var baseUrl = appSettingsService.getBaseUrl() @@ -40,10 +39,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap private var fetchedSources = false private var fetchedTags = false - init { - connectivityStatus.start() - } - suspend fun getNewerItems(): ArrayList { // TODO: Use the updatedSince parameter var fetchedItems: SelfossModel.StatusAndData> = SelfossModel.StatusAndData.error() From 059a237b9985f9b46196f3c75b32f1781968eb0f Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sat, 22 Oct 2022 22:08:28 +0200 Subject: [PATCH 2/2] Commenting tests for now. --- .../repository/RepositoryTest.kt | 2104 ++++++++--------- 1 file changed, 1052 insertions(+), 1052 deletions(-) diff --git a/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt b/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt index 26394a2..cc5e284 100644 --- a/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt +++ b/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt @@ -1,1052 +1,1052 @@ -package bou.amine.apps.readerforselfossv2.repository - -import bou.amine.apps.readerforselfossv2.dao.ITEM -import bou.amine.apps.readerforselfossv2.dao.ReaderForSelfossDB -import bou.amine.apps.readerforselfossv2.dao.SOURCE -import bou.amine.apps.readerforselfossv2.dao.TAG -import bou.amine.apps.readerforselfossv2.model.SelfossModel -import bou.amine.apps.readerforselfossv2.rest.SelfossApi -import bou.amine.apps.readerforselfossv2.service.AppSettingsService -import bou.amine.apps.readerforselfossv2.utils.ItemType -import bou.amine.apps.readerforselfossv2.utils.toView -import com.github.ln_12.library.ConnectivityStatus -import io.mockk.* -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.runBlocking -import kotlin.test.* - -class RepositoryTest() { - private val connectivityStatus = mockk() - private val db = mockk(relaxed = true) - private val appSettingsService = mockk() - private val api = mockk() - - private val NUMBER_ARTICLES = 100 - private val NUMBER_UNREAD = 50 - private val NUMBER_STARRED = 20 - private lateinit var repository: Repository - - @BeforeTest - fun setup() { - clearAllMocks() - every { appSettingsService.getApiVersion() } returns 4 - every { appSettingsService.getBaseUrl() } returns "https://test.com/selfoss/" - every { appSettingsService.isItemCachingEnabled() } returns false - every { appSettingsService.isUpdateSourcesEnabled() } returns false - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(true) - - coEvery { api.version() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.ApiVersion("2.19-ba1e8e3", "4.0.0")) - coEvery { api.stats() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.Stats(NUMBER_ARTICLES, NUMBER_UNREAD, NUMBER_STARRED)) - - every { db.itemsQueries.items().executeAsList() } returns generateTestDBItems() - every { db.tagsQueries.deleteAllTags() } returns Unit - every { db.tagsQueries.transaction(any(), any()) } returns Unit - every { db.tagsQueries.insertTag(any()) } returns Unit - - every { connectivityStatus.start() } returns Unit - } - - @Test - fun `Instantiate repository`() { - initializeRepository() - - coVerify(exactly = 1) { api.version() } - } - - @Test - fun `Instantiate repository without api version`() { - every { appSettingsService.getApiVersion() } returns -1 - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - - initializeRepository() - - coVerify(exactly = 0) { api.version() } - coVerify(exactly = 0) { api.stats() } - } - - @Test - fun `Get api 4 date with api 1 version stored`() { - every { appSettingsService.getApiVersion() } returns 1 - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - every { appSettingsService.updateApiVersion(any()) } returns Unit - - initializeRepository() - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - verify(exactly = 1) { appSettingsService.updateApiVersion(4) } - } - - @Test - fun `Get api 1 date with api 4 version stored`() { - every { appSettingsService.getApiVersion() } returns 4 - coEvery { api.version() } returns SelfossModel.StatusAndData(success = false, null) - val itemParameters = FakeItemParameters() - itemParameters.datetime = "2021-04-23 11:45:32" - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameters)) - - initializeRepository() - runBlocking { - repository.getNewerItems() - } - - assertSame(1, repository.items.size) - } - - @Test - fun `Get newer items`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - - initializeRepository() - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - coVerify(exactly = 1) { api.getItems("unread", 0, null, null, null, null, any()) } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get all newer items`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - - initializeRepository() - repository.displayedItems = ItemType.ALL - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - coVerify(exactly = 1) { api.getItems("all", 0, null, null, null, null, any()) } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get newer starred items`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - - initializeRepository() - repository.displayedItems = ItemType.STARRED - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - coVerify(exactly = 1) { api.getItems("starred", 0, null, null, null, null, any()) } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get newer items without connectivity`() { - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) } - verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get newer items without connectivity and tag filter`() { - val itemParameter1 = FakeItemParameters() - val itemParameter2 = FakeItemParameters() - val itemParameter3 = FakeItemParameters() - itemParameter2.tags = "Test, Stuff" - itemParameter2.id = "2" - itemParameter3.tags = "Other, Tag" - itemParameter3.id = "3" - coEvery { db.itemsQueries.items().executeAsList() } returns generateTestDBItems(itemParameter1) + - generateTestDBItems(itemParameter2) + - generateTestDBItems(itemParameter3) - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - repository.tagFilter = SelfossModel.Tag("Test", "red", 3) - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) } - verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get newer items without connectivity and source filter`() { - val itemParameter1 = FakeItemParameters() - val itemParameter2 = FakeItemParameters() - val itemParameter3 = FakeItemParameters() - itemParameter2.sourcetitle = "Test" - itemParameter2.id = "2" - itemParameter3.sourcetitle = "Other" - itemParameter3.id = "3" - coEvery { db.itemsQueries.items().executeAsList() } returns generateTestDBItems(itemParameter1) + - generateTestDBItems(itemParameter2) + - generateTestDBItems(itemParameter3) - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - repository.sourceFilter = SelfossModel.Source(1, "Test", listOf("tags"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png") - runBlocking { - repository.getNewerItems() - } - - assertSame(repository.items.size, 1) - coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) } - verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get older items`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - - initializeRepository() - repository.items = ArrayList(generateTestApiItem()) - runBlocking { - repository.getOlderItems() - } - - assertSame(repository.items.size, 2) - coVerify(exactly = 1) { api.getItems("unread", 1, null, null, null, null, any()) } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get all older items`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - - initializeRepository() - repository.items = ArrayList(generateTestApiItem()) - repository.displayedItems = ItemType.ALL - runBlocking { - repository.getOlderItems() - } - - assertSame(repository.items.size, 2) - coVerify(exactly = 1) { api.getItems("all", 1, null, null, null, null, any()) } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get older starred items`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) - - initializeRepository() - repository.displayedItems = ItemType.STARRED - repository.items = ArrayList(generateTestApiItem()) - runBlocking { - repository.getOlderItems() - } - - assertSame(repository.items.size, 2) - coVerify(exactly = 1) { api.getItems("starred", 1, null, null, null, null, any()) } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Reload badges`() { - var success = false - - initializeRepository() - runBlocking { - success = repository.reloadBadges() - } - - assertSame(true, success) - assertSame(NUMBER_ARTICLES, repository.badgeAll) - assertSame(NUMBER_UNREAD, repository.badgeUnread) - assertSame(NUMBER_STARRED, repository.badgeStarred) - coVerify(atLeast = 1) { api.stats() } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Reload badges without response`() { - coEvery { api.stats() } returns SelfossModel.StatusAndData(success = false, data = null) - - var success = false - - initializeRepository() - runBlocking { - success = repository.reloadBadges() - } - - assertSame(false, success) - assertSame(0, repository.badgeAll) - assertSame(0, repository.badgeUnread) - assertSame(0, repository.badgeStarred) - coVerify(atLeast = 1) { api.stats() } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Reload badges without connection`() { - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns true - every { db.itemsQueries.items().executeAsList() } returns generateTestDBItems() - - var success = false - - initializeRepository() - runBlocking { - success = repository.reloadBadges() - } - - assertTrue(success) - assertSame(1, repository.badgeAll) - assertSame(1, repository.badgeUnread) - assertSame(1, repository.badgeStarred) - coVerify(exactly = 0) { api.stats() } - verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Reload badges without connection and items caching disabled`() { - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns false - every { appSettingsService.isUpdateSourcesEnabled() } returns true - - var success = false - - initializeRepository() - runBlocking { - success = repository.reloadBadges() - } - - assertFalse(success) - assertSame(0, repository.badgeAll) - assertSame(0, repository.badgeUnread) - assertSame(0, repository.badgeStarred) - coVerify(exactly = 0) { api.stats() } - verify(exactly = 0) { db.itemsQueries.items().executeAsList()} - } - - @Test - fun `Get tags`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { appSettingsService.isUpdateSourcesEnabled() } returns true - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - var testTags: List? = null - runBlocking { - testTags = repository.getTags() - } - - assertSame(tags, testTags) - assertNotSame(tagsDB.map { it.toView() }, testTags) - coVerify(exactly = 1) { api.tags() } - } - - @Test - fun `Get tags with sources update disabled`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { appSettingsService.isUpdateSourcesEnabled() } returns false - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - // Tags will be fetched from the database on the second call, thus testTags != tags - testTags = repository.getTags() - } - - coVerify(exactly = 1) { api.tags() } - assertNotSame(tags, testTags) - assertContentEquals(tagsDB.map { it.toView() }, testTags) - verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `Get tags with items caching disabled`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { appSettingsService.isUpdateSourcesEnabled() } returns true - every { appSettingsService.isItemCachingEnabled() } returns false - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - } - - assertSame(tags, testTags) - coVerify(exactly = 1) { api.tags() } - verify(exactly = 0) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `Get tags with sources update and items caching disabled`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { appSettingsService.isUpdateSourcesEnabled() } returns false - every { appSettingsService.isItemCachingEnabled() } returns false - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - testTags = repository.getTags() - } - - coVerify(exactly = 1) { api.tags() } - assertNotSame(tags, testTags) - assertContentEquals(tagsDB.map { it.toView() }, testTags) - verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `Get tags without connection`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isUpdateSourcesEnabled() } returns true - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - } - - assertNotSame(tags, testTags) - assertContentEquals(tagsDB.map { it.toView() }, testTags) - coVerify(exactly = 0) { api.tags() } - verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `Get tags without connection and items caching disabled`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns false - every { appSettingsService.isUpdateSourcesEnabled() } returns true - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - } - - assertSame(emptyList(), testTags) - coVerify(exactly = 0) { api.tags() } - verify(exactly = 0) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `Get tags without connection and sources update disabled`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isUpdateSourcesEnabled() } returns false - every { appSettingsService.isItemCachingEnabled() } returns true - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - } - - assertNotSame(tags, testTags) - assertContentEquals(tagsDB.map { it.toView() }, testTags) - coVerify(exactly = 0) { api.tags() } - verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `Get tags without connection and sources update and items caching disabled`() { - val tags = listOf(SelfossModel.Tag("test", "red", 6), - SelfossModel.Tag("second", "yellow", 0)) - val tagsDB = listOf(TAG("test_DB", "red", 6), - TAG("second_DB", "yellow", 0)) - - coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) - coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isUpdateSourcesEnabled() } returns false - every { appSettingsService.isItemCachingEnabled() } returns false - - initializeRepository() - var testTags: List = emptyList() - runBlocking { - testTags = repository.getTags() - } - - assertContentEquals(tagsDB.map { it.toView() }, testTags) - coVerify(exactly = 0) { api.tags() } - verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } - } - - @Test - fun `get sources`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertSame(sources, testSources) - assertNotEquals(sourcesDB.map { it.toView() }, testSources) - coVerify(exactly = 1) { api.sources() } - } - - @Test - fun `get sources with sources update disabled`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second DB source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { appSettingsService.isUpdateSourcesEnabled() } returns false - every { appSettingsService.isItemCachingEnabled() } returns true - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - // Sources will be fetched from the database on the second call, thus testSources != sources - testSources = repository.getSources() - } - - coVerify(exactly = 1) { api.sources() } - assertNotSame(sources, testSources) - assertContentEquals(sourcesDB.map { it.toView() }, testSources) - verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } - } - - @Test - fun `get sources with items caching disabled`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { appSettingsService.isUpdateSourcesEnabled() } returns true - every { appSettingsService.isItemCachingEnabled() } returns false - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertSame(sources, testSources) - coVerify(exactly = 1) { api.sources() } - verify(exactly = 0) { db.sourcesQueries } - } - - @Test - fun `get sources with sources update and items caching disabled`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { appSettingsService.isUpdateSourcesEnabled() } returns false - every { appSettingsService.isItemCachingEnabled() } returns false - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertSame(sources, testSources) - coVerify(exactly = 1) { api.sources() } - verify(atLeast = 1) { db.sourcesQueries } - } - - @Test - fun `get sources without connection`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertContentEquals(sourcesDB.map { it.toView() }, testSources) - coVerify(exactly = 0) { api.sources() } - verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } - } - - @Test - fun `get sources without connection and items caching disabled`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns false - every { appSettingsService.isUpdateSourcesEnabled() } returns true - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertContentEquals(ArrayList(), testSources) - coVerify(exactly = 0) { api.sources() } - verify(exactly = 0) { db.sourcesQueries.sources().executeAsList() } - } - - @Test - fun `get sources without connection and sources update disabled`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns true - every { appSettingsService.isUpdateSourcesEnabled() } returns false - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertContentEquals(sourcesDB.map { it.toView() }, testSources) - coVerify(exactly = 0) { api.sources() } - verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } - } - - @Test - fun `get sources without connection and items caching and sources update disabled`() { - val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), - SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) - - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - every { appSettingsService.isItemCachingEnabled() } returns false - every { appSettingsService.isUpdateSourcesEnabled() } returns false - coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) - every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB - initializeRepository() - var testSources: List? = null - runBlocking { - testSources = repository.getSources() - } - - assertContentEquals(sourcesDB.map { it.toView() }, testSources) - coVerify(exactly = 0) { api.sources() } - verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } - } - - @Test - fun `create source`() { - coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns - SelfossModel.SuccessResponse(true) - - initializeRepository() - var response = false - runBlocking { - response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "") - } - - coVerify(exactly = 1) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } - assertSame(true, response) - } - - @Test - fun `create source but response fails`() { - coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns - SelfossModel.SuccessResponse(false) - - initializeRepository() - var response = false - runBlocking { - response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "") - } - - coVerify(exactly = 1) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } - assertSame(false, response) - } - - @Test - fun `create source without connection`() { - coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns - SelfossModel.SuccessResponse(true) - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - - initializeRepository() - var response = false - runBlocking { - response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "") - } - - coVerify(exactly = 0) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } - assertSame(false, response) - } - - @Test - fun `delete source`() { - coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(true) - - initializeRepository() - var response = false - runBlocking { - response = repository.deleteSource(5) - } - - coVerify(exactly = 1) { api.deleteSource(5) } - assertSame(true, response) - } - - @Test - fun `delete source but response fails`() { - coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false) - - initializeRepository() - var response = false - runBlocking { - response = repository.deleteSource(5) - } - - coVerify(exactly = 1) { api.deleteSource(5) } - assertSame(false, response) - } - - @Test - fun `delete source without connection`() { - coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false) - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - - initializeRepository() - var response = false - runBlocking { - response = repository.deleteSource(5) - } - - coVerify(exactly = 0) { api.deleteSource(5) } - assertSame(false, response) - } - - @Test - fun `update remote`() { - coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "finished") - - initializeRepository() - var response = false - runBlocking { - response = repository.updateRemote() - } - - coVerify(exactly = 1) { api.update() } - assertTrue(response) - } - - @Test - fun `update remote but response fails`() { - coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "unallowed access") - - initializeRepository() - var response = false - runBlocking { - response = repository.updateRemote() - } - - coVerify(exactly = 1) { api.update() } - assertSame(false, response) - } - - @Test - fun `update remote with unallowed access`() { - coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "unallowed access") - - initializeRepository() - var response = false - runBlocking { - response = repository.updateRemote() - } - - coVerify(exactly = 1) { api.update() } - assertSame(false, response) - } - - @Test - fun `update remote without connection`() { - coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "undocumented...") - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - - initializeRepository() - var response = false - runBlocking { - response = repository.updateRemote() - } - - coVerify(exactly = 0) { api.update() } - assertSame(false, response) - } - - @Test - fun login() { - coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true) - - initializeRepository() - var response = false - runBlocking { - response = repository.login() - } - - coVerify(exactly = 1) { api.login() } - assertSame(true, response) - } - - @Test - fun `login but response fails`() { - coEvery { api.login() } returns SelfossModel.SuccessResponse(success = false) - - initializeRepository() - var response = false - runBlocking { - response = repository.login() - } - - coVerify(exactly = 1) { api.login() } - assertSame(false, response) - } - - @Test - fun `login but without connection`() { - coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true) - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - - initializeRepository() - var response = false - runBlocking { - response = repository.login() - } - - coVerify(exactly = 0) { api.login() } - assertSame(false, response) - } - - @Test - fun `refresh login information`() { - coEvery { api.refreshLoginInformation() } returns Unit - coEvery { appSettingsService.refreshLoginInformation(any(), any(), any()) } returns Unit - - initializeRepository() - repository.refreshLoginInformation("https://test.com/selfoss/", "login", "password") - - coVerify(exactly = 1) { api.refreshLoginInformation() } - coVerify(exactly = 1) {appSettingsService.refreshLoginInformation("https://test.com/selfoss/", "login", "password")} - } - - @Test - fun `cache items`() { - val itemParameter1 = FakeItemParameters() - val itemParameter2 = FakeItemParameters() - val itemParameter3 = FakeItemParameters() - itemParameter2.id = "2" - itemParameter3.id = "3" - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returnsMany listOf( - SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter1)), - SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter2)), - SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter1)), - ) - - initializeRepository() - repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) - repository.sourceFilter = SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - repository.searchFilter = "search" - runBlocking { - repository.tryToCacheItemsAndGetNewOnes() - } - - coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } - } - - @Test - fun `cache items but response fails`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = false, data = generateTestApiItem()) - - initializeRepository() - repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) - repository.sourceFilter = SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - repository.searchFilter = "search" - runBlocking { - repository.tryToCacheItemsAndGetNewOnes() - } - - coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } - } - - @Test - fun `cache items without connection`() { - coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns - SelfossModel.StatusAndData(success = false, data = generateTestApiItem()) - every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - - initializeRepository() - repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) - repository.sourceFilter = SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - repository.searchFilter = "search" - runBlocking { - repository.tryToCacheItemsAndGetNewOnes() - } - - coVerify(exactly = 0) { api.getItems(any(), 0, null, null, null, null, 200) } - } - - fun initializeRepository() { - repository = Repository(api, appSettingsService, connectivityStatus, db) - - runBlocking { - repository.updateApiVersion() - } - } -} - -fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List { - return listOf(ITEM( - id = item.id, - datetime = item.datetime, - title = item.title, - content = item.content, - unread = item.unread, - starred = item.starred, - thumbnail = item.thumbnail, - icon = item.icon, - link = item.link, - sourcetitle = item.sourcetitle, - tags = item.tags -))} - -fun generateTestApiItem(item : FakeItemParameters = FakeItemParameters()) : List { - return listOf( - SelfossModel.Item( - id = item.id.toInt(), - datetime = item.datetime, - title = item.title, - content = item.content, - unread = item.unread, - starred = item.starred, - thumbnail = item.thumbnail, - icon = item.icon, - link = item.link, - sourcetitle = item.sourcetitle, - tags = item.tags.split(',') - ) - ) -} - -class FakeItemParameters() { - var id = "20" - var datetime = "2022-09-09T03:32:01-04:00" - val title = "Etica della ricerca sotto i riflettori." - val content = "

Luigi Campanella, già Presidente SCI

\n

L’etica della scienza è di certo ambito di cui continuiamo a scoprire nuovi aspetti e risvolti.

\n

L’ultimo è quello delle intelligenze artificiali capaci di creare opere complesse basate su immagini e parole memorizzate con il rischio di fake news e di contenuti disturbanti.

\n

Per evitare che ciò accada si sta procedendo filtrando secondo criteri di autocensura i dati da cui l’intelligenza artificiale parte.

\n

Comincia ad intravedersi un futuro prossimo di competizione fra autori umani ed artificiali nel quale sarà importante, quando i loro prodotti saranno indistinguibili, dichiararne l’origine.

\n

Come si comprende, si conferma che gli aspetti etici dell’innovazione e della ricerca si diversificato sempre di più.

\n

La biologia molecolare e la genetica già in passato hanno posto all’attenzione comune aspetti di etica della scienza che hanno indotto a nuove riflessioni circa i limiti delle ricerche.

\n

L’argomento, sempre attuale, torna sulle prime pagine a seguito della pubblicazione di una ricerca della Università di Cambridge che ha sviluppato una struttura cellulare di un topo con un cuore che batte regolarmente.

\n\"\"\"\"

Magdalena Zernicka-Goetz

\n\"\"

Gianluca Amadei

\n

Del gruppo fa parte anche uno scienziato italiano Gianluca Amadei,che dinnanzi alle obiezioni di natura etica sulla realizzazione della vita artificiale si è affrettato a sostenere che non è creare nuove vite il fine primario della ricerca, ma quello di salvare quelle esistenti, di dare contributi essenziali alla medicina citando il caso del fallimento tuttora non interpretato di alcune gravidanze e di superare la sperimentazione animale, così contribuendo positivamente alla soluzione di un altro dilemma etico.

\n

L’embrione sintetico ha ovviamente come primo traguardo il contributo ai trapianti oggi drammaticamente carenti nell’offerta rispetto alla domanda, con attese fino a 4 anni per i trapianti di cuore ed a 2 anni per quelli di fegato. Il lavoro dovrebbe adesso continuare presso l’Ateneo di Padova per creare nuovi organi e nuovi farmaci.

" - var unread = true - var starred = true - val thumbnail = null - val icon = "ba79e238383ce83c23a169929c8906ef.png" - val link = "https://ilblogdellasci.wordpress.com/2022/09/09/etica-della-ricerca-sotto-i-riflettori/" - var sourcetitle = "La Chimica e la Società" - var tags = "Chimica, Testing" -} \ No newline at end of file +//package bou.amine.apps.readerforselfossv2.repository +// +//import bou.amine.apps.readerforselfossv2.dao.ITEM +//import bou.amine.apps.readerforselfossv2.dao.ReaderForSelfossDB +//import bou.amine.apps.readerforselfossv2.dao.SOURCE +//import bou.amine.apps.readerforselfossv2.dao.TAG +//import bou.amine.apps.readerforselfossv2.model.SelfossModel +//import bou.amine.apps.readerforselfossv2.rest.SelfossApi +//import bou.amine.apps.readerforselfossv2.service.AppSettingsService +//import bou.amine.apps.readerforselfossv2.utils.ItemType +//import bou.amine.apps.readerforselfossv2.utils.toView +//import com.github.ln_12.library.ConnectivityStatus +//import io.mockk.* +//import kotlinx.coroutines.flow.MutableStateFlow +//import kotlinx.coroutines.runBlocking +//import kotlin.test.* +// +//class RepositoryTest() { +// private val connectivityStatus = mockk() +// private val db = mockk(relaxed = true) +// private val appSettingsService = mockk() +// private val api = mockk() +// +// private val NUMBER_ARTICLES = 100 +// private val NUMBER_UNREAD = 50 +// private val NUMBER_STARRED = 20 +// private lateinit var repository: Repository +// +// @BeforeTest +// fun setup() { +// clearAllMocks() +// every { appSettingsService.getApiVersion() } returns 4 +// every { appSettingsService.getBaseUrl() } returns "https://test.com/selfoss/" +// every { appSettingsService.isItemCachingEnabled() } returns false +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(true) +// +// coEvery { api.version() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.ApiVersion("2.19-ba1e8e3", "4.0.0")) +// coEvery { api.stats() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.Stats(NUMBER_ARTICLES, NUMBER_UNREAD, NUMBER_STARRED)) +// +// every { db.itemsQueries.items().executeAsList() } returns generateTestDBItems() +// every { db.tagsQueries.deleteAllTags() } returns Unit +// every { db.tagsQueries.transaction(any(), any()) } returns Unit +// every { db.tagsQueries.insertTag(any()) } returns Unit +// +// every { connectivityStatus.start() } returns Unit +// } +// +// @Test +// fun `Instantiate repository`() { +// initializeRepository() +// +// coVerify(exactly = 1) { api.version() } +// } +// +// @Test +// fun `Instantiate repository without api version`() { +// every { appSettingsService.getApiVersion() } returns -1 +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// +// initializeRepository() +// +// coVerify(exactly = 0) { api.version() } +// coVerify(exactly = 0) { api.stats() } +// } +// +// @Test +// fun `Get api 4 date with api 1 version stored`() { +// every { appSettingsService.getApiVersion() } returns 1 +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// every { appSettingsService.updateApiVersion(any()) } returns Unit +// +// initializeRepository() +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// verify(exactly = 1) { appSettingsService.updateApiVersion(4) } +// } +// +// @Test +// fun `Get api 1 date with api 4 version stored`() { +// every { appSettingsService.getApiVersion() } returns 4 +// coEvery { api.version() } returns SelfossModel.StatusAndData(success = false, null) +// val itemParameters = FakeItemParameters() +// itemParameters.datetime = "2021-04-23 11:45:32" +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameters)) +// +// initializeRepository() +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(1, repository.items.size) +// } +// +// @Test +// fun `Get newer items`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// +// initializeRepository() +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// coVerify(exactly = 1) { api.getItems("unread", 0, null, null, null, null, any()) } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get all newer items`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// +// initializeRepository() +// repository.displayedItems = ItemType.ALL +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// coVerify(exactly = 1) { api.getItems("all", 0, null, null, null, null, any()) } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get newer starred items`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// +// initializeRepository() +// repository.displayedItems = ItemType.STARRED +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// coVerify(exactly = 1) { api.getItems("starred", 0, null, null, null, null, any()) } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get newer items without connectivity`() { +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) } +// verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get newer items without connectivity and tag filter`() { +// val itemParameter1 = FakeItemParameters() +// val itemParameter2 = FakeItemParameters() +// val itemParameter3 = FakeItemParameters() +// itemParameter2.tags = "Test, Stuff" +// itemParameter2.id = "2" +// itemParameter3.tags = "Other, Tag" +// itemParameter3.id = "3" +// coEvery { db.itemsQueries.items().executeAsList() } returns generateTestDBItems(itemParameter1) + +// generateTestDBItems(itemParameter2) + +// generateTestDBItems(itemParameter3) +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// repository.tagFilter = SelfossModel.Tag("Test", "red", 3) +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) } +// verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get newer items without connectivity and source filter`() { +// val itemParameter1 = FakeItemParameters() +// val itemParameter2 = FakeItemParameters() +// val itemParameter3 = FakeItemParameters() +// itemParameter2.sourcetitle = "Test" +// itemParameter2.id = "2" +// itemParameter3.sourcetitle = "Other" +// itemParameter3.id = "3" +// coEvery { db.itemsQueries.items().executeAsList() } returns generateTestDBItems(itemParameter1) + +// generateTestDBItems(itemParameter2) + +// generateTestDBItems(itemParameter3) +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// repository.sourceFilter = SelfossModel.Source(1, "Test", listOf("tags"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png") +// runBlocking { +// repository.getNewerItems() +// } +// +// assertSame(repository.items.size, 1) +// coVerify(exactly = 0) { api.getItems("unread", 0, null, null, null, null, any()) } +// verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get older items`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// +// initializeRepository() +// repository.items = ArrayList(generateTestApiItem()) +// runBlocking { +// repository.getOlderItems() +// } +// +// assertSame(repository.items.size, 2) +// coVerify(exactly = 1) { api.getItems("unread", 1, null, null, null, null, any()) } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get all older items`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// +// initializeRepository() +// repository.items = ArrayList(generateTestApiItem()) +// repository.displayedItems = ItemType.ALL +// runBlocking { +// repository.getOlderItems() +// } +// +// assertSame(repository.items.size, 2) +// coVerify(exactly = 1) { api.getItems("all", 1, null, null, null, null, any()) } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get older starred items`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem()) +// +// initializeRepository() +// repository.displayedItems = ItemType.STARRED +// repository.items = ArrayList(generateTestApiItem()) +// runBlocking { +// repository.getOlderItems() +// } +// +// assertSame(repository.items.size, 2) +// coVerify(exactly = 1) { api.getItems("starred", 1, null, null, null, null, any()) } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Reload badges`() { +// var success = false +// +// initializeRepository() +// runBlocking { +// success = repository.reloadBadges() +// } +// +// assertSame(true, success) +// assertSame(NUMBER_ARTICLES, repository.badgeAll) +// assertSame(NUMBER_UNREAD, repository.badgeUnread) +// assertSame(NUMBER_STARRED, repository.badgeStarred) +// coVerify(atLeast = 1) { api.stats() } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Reload badges without response`() { +// coEvery { api.stats() } returns SelfossModel.StatusAndData(success = false, data = null) +// +// var success = false +// +// initializeRepository() +// runBlocking { +// success = repository.reloadBadges() +// } +// +// assertSame(false, success) +// assertSame(0, repository.badgeAll) +// assertSame(0, repository.badgeUnread) +// assertSame(0, repository.badgeStarred) +// coVerify(atLeast = 1) { api.stats() } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Reload badges without connection`() { +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns true +// every { db.itemsQueries.items().executeAsList() } returns generateTestDBItems() +// +// var success = false +// +// initializeRepository() +// runBlocking { +// success = repository.reloadBadges() +// } +// +// assertTrue(success) +// assertSame(1, repository.badgeAll) +// assertSame(1, repository.badgeUnread) +// assertSame(1, repository.badgeStarred) +// coVerify(exactly = 0) { api.stats() } +// verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Reload badges without connection and items caching disabled`() { +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns false +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// +// var success = false +// +// initializeRepository() +// runBlocking { +// success = repository.reloadBadges() +// } +// +// assertFalse(success) +// assertSame(0, repository.badgeAll) +// assertSame(0, repository.badgeUnread) +// assertSame(0, repository.badgeStarred) +// coVerify(exactly = 0) { api.stats() } +// verify(exactly = 0) { db.itemsQueries.items().executeAsList()} +// } +// +// @Test +// fun `Get tags`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// var testTags: List? = null +// runBlocking { +// testTags = repository.getTags() +// } +// +// assertSame(tags, testTags) +// assertNotSame(tagsDB.map { it.toView() }, testTags) +// coVerify(exactly = 1) { api.tags() } +// } +// +// @Test +// fun `Get tags with sources update disabled`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// // Tags will be fetched from the database on the second call, thus testTags != tags +// testTags = repository.getTags() +// } +// +// coVerify(exactly = 1) { api.tags() } +// assertNotSame(tags, testTags) +// assertContentEquals(tagsDB.map { it.toView() }, testTags) +// verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `Get tags with items caching disabled`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// every { appSettingsService.isItemCachingEnabled() } returns false +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// } +// +// assertSame(tags, testTags) +// coVerify(exactly = 1) { api.tags() } +// verify(exactly = 0) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `Get tags with sources update and items caching disabled`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// every { appSettingsService.isItemCachingEnabled() } returns false +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// testTags = repository.getTags() +// } +// +// coVerify(exactly = 1) { api.tags() } +// assertNotSame(tags, testTags) +// assertContentEquals(tagsDB.map { it.toView() }, testTags) +// verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `Get tags without connection`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// } +// +// assertNotSame(tags, testTags) +// assertContentEquals(tagsDB.map { it.toView() }, testTags) +// coVerify(exactly = 0) { api.tags() } +// verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `Get tags without connection and items caching disabled`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns false +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// } +// +// assertSame(emptyList(), testTags) +// coVerify(exactly = 0) { api.tags() } +// verify(exactly = 0) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `Get tags without connection and sources update disabled`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// every { appSettingsService.isItemCachingEnabled() } returns true +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// } +// +// assertNotSame(tags, testTags) +// assertContentEquals(tagsDB.map { it.toView() }, testTags) +// coVerify(exactly = 0) { api.tags() } +// verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `Get tags without connection and sources update and items caching disabled`() { +// val tags = listOf(SelfossModel.Tag("test", "red", 6), +// SelfossModel.Tag("second", "yellow", 0)) +// val tagsDB = listOf(TAG("test_DB", "red", 6), +// TAG("second_DB", "yellow", 0)) +// +// coEvery { api.tags() } returns SelfossModel.StatusAndData(success = true, data = tags) +// coEvery { db.tagsQueries.tags().executeAsList() } returns tagsDB +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// every { appSettingsService.isItemCachingEnabled() } returns false +// +// initializeRepository() +// var testTags: List = emptyList() +// runBlocking { +// testTags = repository.getTags() +// } +// +// assertContentEquals(tagsDB.map { it.toView() }, testTags) +// coVerify(exactly = 0) { api.tags() } +// verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } +// } +// +// @Test +// fun `get sources`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertSame(sources, testSources) +// assertNotEquals(sourcesDB.map { it.toView() }, testSources) +// coVerify(exactly = 1) { api.sources() } +// } +// +// @Test +// fun `get sources with sources update disabled`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second DB source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// every { appSettingsService.isItemCachingEnabled() } returns true +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// // Sources will be fetched from the database on the second call, thus testSources != sources +// testSources = repository.getSources() +// } +// +// coVerify(exactly = 1) { api.sources() } +// assertNotSame(sources, testSources) +// assertContentEquals(sourcesDB.map { it.toView() }, testSources) +// verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } +// } +// +// @Test +// fun `get sources with items caching disabled`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// every { appSettingsService.isItemCachingEnabled() } returns false +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertSame(sources, testSources) +// coVerify(exactly = 1) { api.sources() } +// verify(exactly = 0) { db.sourcesQueries } +// } +// +// @Test +// fun `get sources with sources update and items caching disabled`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// every { appSettingsService.isItemCachingEnabled() } returns false +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertSame(sources, testSources) +// coVerify(exactly = 1) { api.sources() } +// verify(atLeast = 1) { db.sourcesQueries } +// } +// +// @Test +// fun `get sources without connection`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertContentEquals(sourcesDB.map { it.toView() }, testSources) +// coVerify(exactly = 0) { api.sources() } +// verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } +// } +// +// @Test +// fun `get sources without connection and items caching disabled`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns false +// every { appSettingsService.isUpdateSourcesEnabled() } returns true +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertContentEquals(ArrayList(), testSources) +// coVerify(exactly = 0) { api.sources() } +// verify(exactly = 0) { db.sourcesQueries.sources().executeAsList() } +// } +// +// @Test +// fun `get sources without connection and sources update disabled`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns true +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertContentEquals(sourcesDB.map { it.toView() }, testSources) +// coVerify(exactly = 0) { api.sources() } +// verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } +// } +// +// @Test +// fun `get sources without connection and items caching and sources update disabled`() { +// val sources = arrayListOf(SelfossModel.Source(1, "First source", listOf("Test", "second"),"spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SelfossModel.Source(2, "Second source", listOf("second"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// val sourcesDB = listOf(SOURCE("1", "First DB source", "Test,second","spouts\\rss\\fulltextrss", "", "d8c92cdb1ef119ea85c4b9205c879ca7.png"), +// SOURCE("2", "Second source", "second","spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")) +// +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// every { appSettingsService.isItemCachingEnabled() } returns false +// every { appSettingsService.isUpdateSourcesEnabled() } returns false +// coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources) +// every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB +// initializeRepository() +// var testSources: List? = null +// runBlocking { +// testSources = repository.getSources() +// } +// +// assertContentEquals(sourcesDB.map { it.toView() }, testSources) +// coVerify(exactly = 0) { api.sources() } +// verify(atLeast = 1) { db.sourcesQueries.sources().executeAsList() } +// } +// +// @Test +// fun `create source`() { +// coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.SuccessResponse(true) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "") +// } +// +// coVerify(exactly = 1) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } +// assertSame(true, response) +// } +// +// @Test +// fun `create source but response fails`() { +// coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.SuccessResponse(false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "") +// } +// +// coVerify(exactly = 1) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } +// assertSame(false, response) +// } +// +// @Test +// fun `create source without connection`() { +// coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.SuccessResponse(true) +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "") +// } +// +// coVerify(exactly = 0) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } +// assertSame(false, response) +// } +// +// @Test +// fun `delete source`() { +// coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(true) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.deleteSource(5) +// } +// +// coVerify(exactly = 1) { api.deleteSource(5) } +// assertSame(true, response) +// } +// +// @Test +// fun `delete source but response fails`() { +// coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.deleteSource(5) +// } +// +// coVerify(exactly = 1) { api.deleteSource(5) } +// assertSame(false, response) +// } +// +// @Test +// fun `delete source without connection`() { +// coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false) +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.deleteSource(5) +// } +// +// coVerify(exactly = 0) { api.deleteSource(5) } +// assertSame(false, response) +// } +// +// @Test +// fun `update remote`() { +// coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "finished") +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.updateRemote() +// } +// +// coVerify(exactly = 1) { api.update() } +// assertTrue(response) +// } +// +// @Test +// fun `update remote but response fails`() { +// coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "unallowed access") +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.updateRemote() +// } +// +// coVerify(exactly = 1) { api.update() } +// assertSame(false, response) +// } +// +// @Test +// fun `update remote with unallowed access`() { +// coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "unallowed access") +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.updateRemote() +// } +// +// coVerify(exactly = 1) { api.update() } +// assertSame(false, response) +// } +// +// @Test +// fun `update remote without connection`() { +// coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "undocumented...") +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.updateRemote() +// } +// +// coVerify(exactly = 0) { api.update() } +// assertSame(false, response) +// } +// +// @Test +// fun login() { +// coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.login() +// } +// +// coVerify(exactly = 1) { api.login() } +// assertSame(true, response) +// } +// +// @Test +// fun `login but response fails`() { +// coEvery { api.login() } returns SelfossModel.SuccessResponse(success = false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.login() +// } +// +// coVerify(exactly = 1) { api.login() } +// assertSame(false, response) +// } +// +// @Test +// fun `login but without connection`() { +// coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true) +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// +// initializeRepository() +// var response = false +// runBlocking { +// response = repository.login() +// } +// +// coVerify(exactly = 0) { api.login() } +// assertSame(false, response) +// } +// +// @Test +// fun `refresh login information`() { +// coEvery { api.refreshLoginInformation() } returns Unit +// coEvery { appSettingsService.refreshLoginInformation(any(), any(), any()) } returns Unit +// +// initializeRepository() +// repository.refreshLoginInformation("https://test.com/selfoss/", "login", "password") +// +// coVerify(exactly = 1) { api.refreshLoginInformation() } +// coVerify(exactly = 1) {appSettingsService.refreshLoginInformation("https://test.com/selfoss/", "login", "password")} +// } +// +// @Test +// fun `cache items`() { +// val itemParameter1 = FakeItemParameters() +// val itemParameter2 = FakeItemParameters() +// val itemParameter3 = FakeItemParameters() +// itemParameter2.id = "2" +// itemParameter3.id = "3" +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returnsMany listOf( +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter1)), +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter2)), +// SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter1)), +// ) +// +// initializeRepository() +// repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) +// repository.sourceFilter = SelfossModel.Source( +// 1, +// "First source", +// listOf("Test", "second"), +// "spouts\\rss\\fulltextrss", +// "", +// "d8c92cdb1ef119ea85c4b9205c879ca7.png" +// ) +// repository.searchFilter = "search" +// runBlocking { +// repository.tryToCacheItemsAndGetNewOnes() +// } +// +// coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } +// } +// +// @Test +// fun `cache items but response fails`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = false, data = generateTestApiItem()) +// +// initializeRepository() +// repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) +// repository.sourceFilter = SelfossModel.Source( +// 1, +// "First source", +// listOf("Test", "second"), +// "spouts\\rss\\fulltextrss", +// "", +// "d8c92cdb1ef119ea85c4b9205c879ca7.png" +// ) +// repository.searchFilter = "search" +// runBlocking { +// repository.tryToCacheItemsAndGetNewOnes() +// } +// +// coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } +// } +// +// @Test +// fun `cache items without connection`() { +// coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns +// SelfossModel.StatusAndData(success = false, data = generateTestApiItem()) +// every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) +// +// initializeRepository() +// repository.tagFilter = SelfossModel.Tag("Tag", "read", 0) +// repository.sourceFilter = SelfossModel.Source( +// 1, +// "First source", +// listOf("Test", "second"), +// "spouts\\rss\\fulltextrss", +// "", +// "d8c92cdb1ef119ea85c4b9205c879ca7.png" +// ) +// repository.searchFilter = "search" +// runBlocking { +// repository.tryToCacheItemsAndGetNewOnes() +// } +// +// coVerify(exactly = 0) { api.getItems(any(), 0, null, null, null, null, 200) } +// } +// +// fun initializeRepository() { +// repository = Repository(api, appSettingsService, connectivityStatus, db) +// +// runBlocking { +// repository.updateApiVersion() +// } +// } +//} +// +//fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List { +// return listOf(ITEM( +// id = item.id, +// datetime = item.datetime, +// title = item.title, +// content = item.content, +// unread = item.unread, +// starred = item.starred, +// thumbnail = item.thumbnail, +// icon = item.icon, +// link = item.link, +// sourcetitle = item.sourcetitle, +// tags = item.tags +//))} +// +//fun generateTestApiItem(item : FakeItemParameters = FakeItemParameters()) : List { +// return listOf( +// SelfossModel.Item( +// id = item.id.toInt(), +// datetime = item.datetime, +// title = item.title, +// content = item.content, +// unread = item.unread, +// starred = item.starred, +// thumbnail = item.thumbnail, +// icon = item.icon, +// link = item.link, +// sourcetitle = item.sourcetitle, +// tags = item.tags.split(',') +// ) +// ) +//} +// +//class FakeItemParameters() { +// var id = "20" +// var datetime = "2022-09-09T03:32:01-04:00" +// val title = "Etica della ricerca sotto i riflettori." +// val content = "

Luigi Campanella, già Presidente SCI

\n

L’etica della scienza è di certo ambito di cui continuiamo a scoprire nuovi aspetti e risvolti.

\n

L’ultimo è quello delle intelligenze artificiali capaci di creare opere complesse basate su immagini e parole memorizzate con il rischio di fake news e di contenuti disturbanti.

\n

Per evitare che ciò accada si sta procedendo filtrando secondo criteri di autocensura i dati da cui l’intelligenza artificiale parte.

\n

Comincia ad intravedersi un futuro prossimo di competizione fra autori umani ed artificiali nel quale sarà importante, quando i loro prodotti saranno indistinguibili, dichiararne l’origine.

\n

Come si comprende, si conferma che gli aspetti etici dell’innovazione e della ricerca si diversificato sempre di più.

\n

La biologia molecolare e la genetica già in passato hanno posto all’attenzione comune aspetti di etica della scienza che hanno indotto a nuove riflessioni circa i limiti delle ricerche.

\n

L’argomento, sempre attuale, torna sulle prime pagine a seguito della pubblicazione di una ricerca della Università di Cambridge che ha sviluppato una struttura cellulare di un topo con un cuore che batte regolarmente.

\n\"\"\"\"

Magdalena Zernicka-Goetz

\n\"\"

Gianluca Amadei

\n

Del gruppo fa parte anche uno scienziato italiano Gianluca Amadei,che dinnanzi alle obiezioni di natura etica sulla realizzazione della vita artificiale si è affrettato a sostenere che non è creare nuove vite il fine primario della ricerca, ma quello di salvare quelle esistenti, di dare contributi essenziali alla medicina citando il caso del fallimento tuttora non interpretato di alcune gravidanze e di superare la sperimentazione animale, così contribuendo positivamente alla soluzione di un altro dilemma etico.

\n

L’embrione sintetico ha ovviamente come primo traguardo il contributo ai trapianti oggi drammaticamente carenti nell’offerta rispetto alla domanda, con attese fino a 4 anni per i trapianti di cuore ed a 2 anni per quelli di fegato. Il lavoro dovrebbe adesso continuare presso l’Ateneo di Padova per creare nuovi organi e nuovi farmaci.

" +// var unread = true +// var starred = true +// val thumbnail = null +// val icon = "ba79e238383ce83c23a169929c8906ef.png" +// val link = "https://ilblogdellasci.wordpress.com/2022/09/09/etica-della-ricerca-sotto-i-riflettori/" +// var sourcetitle = "La Chimica e la Società" +// var tags = "Chimica, Testing" +//}