remove database -> shared dependency

This commit is contained in:
Milos Kozak 2022-11-02 21:49:44 +01:00
parent 7ec1049276
commit bf14292b98
4 changed files with 26 additions and 6 deletions

View file

@ -20,9 +20,6 @@ android {
} }
dependencies { dependencies {
// shared needed for OpenForTesting
implementation project(':shared')
api "androidx.core:core-ktx:$core_version" api "androidx.core:core-ktx:$core_version"
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
@ -48,5 +45,5 @@ dependencies {
allOpen { allOpen {
// allows mocking for classes w/o directly opening them for release builds // allows mocking for classes w/o directly opening them for release builds
annotation 'info.nightscout.androidaps.annotations.OpenForTesting' annotation 'info.nightscout.androidaps.annotations.DbOpenForTesting'
} }

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.annotations
/**
* This is the actual annotation that makes the class open. Don't use it directly, only through [DbOpenForTesting]
* which has a NOOP replacement in production.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
annotation class DbOpenClass
/**
* Annotate a class with [DbOpenForTesting] if it should be extendable for testing.
*/
@DbOpenClass
@Target(AnnotationTarget.CLASS)
annotation class DbOpenForTesting

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.database package info.nightscout.androidaps.database
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.DbOpenForTesting
import info.nightscout.androidaps.database.data.NewEntries import info.nightscout.androidaps.database.data.NewEntries
import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.embedments.InterfaceIDs
import info.nightscout.androidaps.database.entities.* import info.nightscout.androidaps.database.entities.*
@ -19,7 +19,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.roundToInt import kotlin.math.roundToInt
@OpenForTesting @DbOpenForTesting
@Singleton class AppRepository @Inject internal constructor( @Singleton class AppRepository @Inject internal constructor(
internal val database: AppDatabase internal val database: AppDatabase
) { ) {

View file

@ -0,0 +1,8 @@
package info.nightscout.androidaps.annotations
/**
* Annotate a class with [DbOpenForTesting] if it should be extendable for testing.
* In production the class remains final.
*/
@Target(AnnotationTarget.CLASS)
annotation class DbOpenForTesting