unify @OpenForTesting

This commit is contained in:
Milos Kozak 2021-11-18 15:47:42 +01:00
parent 9fb20917c5
commit 301fa49e38
6 changed files with 36 additions and 41 deletions

View file

@ -11,23 +11,32 @@ apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle"
apply from: "${project.rootDir}/gradle/test_dependencies.gradle" apply from: "${project.rootDir}/gradle/test_dependencies.gradle"
apply from: "${project.rootDir}/gradle/jacoco_global.gradle" apply from: "${project.rootDir}/gradle/jacoco_global.gradle"
allOpen {
annotation 'info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenClass'
}
detekt { // TODO move to `subprojects` section in global build.gradle detekt { // TODO move to `subprojects` section in global build.gradle
toolVersion = "1.15.0-RC2" toolVersion = "1.15.0-RC2"
config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml" config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml"
} }
android {
defaultConfig {
kapt {
arguments {
arg("room.incremental", "true")
arg("room.schemaLocation", "$projectDir/schemas")
}
}
}
}
dependencies { dependencies {
implementation project(':core') implementation project(':core')
implementation project(':pump-common') implementation project(':pump-common')
implementation project(':omnipod-common') implementation project(':omnipod-common')
implementation project(':database')
implementation "androidx.room:room-runtime:$room_version" api "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-rxjava2:$room_version" api "androidx.room:room-runtime:$room_version"
implementation project(path: ':pump-common') api "androidx.room:room-rxjava2:$room_version"
kapt "androidx.room:room-compiler:$room_version" kapt "androidx.room:room-compiler:$room_version"
implementation 'com.github.guepardoapps:kulid:2.0.0.0'
api 'com.github.guepardoapps:kulid:2.0.0.0'
} }

View file

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

View file

@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import java.security.SecureRandom import java.security.SecureRandom
@OpenForTesting @OpenForTesting

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
import com.google.crypto.tink.subtle.X25519 import com.google.crypto.tink.subtle.X25519
import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
@OpenForTesting @OpenForTesting
class X25519KeyGenerator { class X25519KeyGenerator {

View file

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

View file

@ -9,21 +9,30 @@ apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle"
apply from: "${project.rootDir}/gradle/test_dependencies.gradle" apply from: "${project.rootDir}/gradle/test_dependencies.gradle"
apply from: "${project.rootDir}/gradle/jacoco_global.gradle" apply from: "${project.rootDir}/gradle/jacoco_global.gradle"
android {
defaultConfig {
kapt {
arguments {
arg("room.incremental", "true")
arg("room.schemaLocation", "$projectDir/schemas")
}
}
}
}
dependencies { dependencies {
implementation project(':core') implementation project(':core')
implementation project(':pump-common') implementation project(':pump-common')
implementation project(':omnipod-common') implementation project(':omnipod-common')
implementation project(':rileylink') implementation project(':rileylink')
implementation project(':database')
implementation "androidx.room:room-runtime:$room_version" api "androidx.room:room-ktx:$room_version"
annotationProcessor("androidx.room:room-compiler:$room_version") api "androidx.room:room-runtime:$room_version"
// To use Kotlin annotation processing tool (kapt) api "androidx.room:room-rxjava2:$room_version"
kapt("androidx.room:room-compiler:$room_version") kapt "androidx.room:room-compiler:$room_version"
// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:$room_version")
// optional - RxJava2 support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// optional - Test helpers // optional - Test helpers
testImplementation("androidx.room:room-testing:$room_version") testImplementation("androidx.room:room-testing:$room_version")
} }