From ea4fec531494a8cd2d5ec85dcf7a2ef3e665636f Mon Sep 17 00:00:00 2001
From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com>
Date: Fri, 12 Mar 2021 15:25:50 +0100
Subject: [PATCH] Add check in risk to RiskLevelResult (DEV) (#2595)

* extend risk level result with check in risk

* extend risk level result with check in risk

* extend risk level result with check in risk

* klint

* klint

* convert to interface

* convert to interface
---
 .../java/de/rki/coronawarnapp/risk/RiskLevelResult.kt  |  2 ++
 .../coronawarnapp/risk/RiskLevelResultExtensions.kt    |  4 ++++
 .../de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt   |  3 +++
 .../rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt |  6 ++++++
 .../analytics/modules/ExposureRiskMetadataDonorTest.kt |  3 +++
 .../coronawarnapp/risk/RiskLevelChangeDetectorTest.kt  |  2 ++
 .../risk/RiskLevelResultExtensionsTest.kt              | 10 ++++++----
 .../de/rki/coronawarnapp/risk/RiskLevelResultTest.kt   |  2 ++
 8 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt

diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt
index 1feb415e7..6424a0ef5 100644
--- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResult.kt
@@ -49,6 +49,8 @@ interface RiskLevelResult {
             aggregatedRiskResult?.mostRecentDateWithLowRisk
         }
 
+    val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+
     enum class FailureReason(val failureCode: String) {
         UNKNOWN("unknown"),
         TRACING_OFF("tracingOff"),
diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt
index 8911020fc..7ce685ff0 100644
--- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensions.kt
@@ -30,6 +30,8 @@ private object InitialLowLevelRiskLevelResult : RiskLevelResult {
     override val exposureWindows: List<ExposureWindow>? = null
     override val matchedKeyCount: Int = 0
     override val daysWithEncounters: Int = 0
+    override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+        get() = emptyList() // TODO("Not yet implemented")
 }
 
 private object UndeterminedRiskLevelResult : RiskLevelResult {
@@ -40,4 +42,6 @@ private object UndeterminedRiskLevelResult : RiskLevelResult {
     override val exposureWindows: List<ExposureWindow>? = null
     override val matchedKeyCount: Int = 0
     override val daysWithEncounters: Int = 0
+    override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+        get() = emptyList() // TODO("Not yet implemented")
 }
diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt
index deddc698d..bdb133d2e 100644
--- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskLevelTaskResult.kt
@@ -33,6 +33,9 @@ data class RiskLevelTaskResult(
         exposureWindows = null
     )
 
+    override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+        get() = emptyList() // TODO("Not yet implemented")
+
     override fun toString(): String = "RiskLevelTaskResult(" +
         "calculatedAt=$calculatedAt, " +
         "failureReason=$failureReason, " +
diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt
new file mode 100644
index 000000000..b62398a1c
--- /dev/null
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/TraceLocationCheckInRisk.kt
@@ -0,0 +1,6 @@
+package de.rki.coronawarnapp.risk
+
+interface TraceLocationCheckInRisk {
+    val checkInId: Long
+    val riskState: RiskState
+}
diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt
index 8e65fb16c..f40a42669 100644
--- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt
+++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/ExposureRiskMetadataDonorTest.kt
@@ -5,6 +5,7 @@ import de.rki.coronawarnapp.appconfig.ConfigData
 import de.rki.coronawarnapp.datadonation.analytics.modules.exposureriskmetadata.ExposureRiskMetadataDonor
 import de.rki.coronawarnapp.datadonation.analytics.storage.AnalyticsSettings
 import de.rki.coronawarnapp.risk.RiskLevelResult
+import de.rki.coronawarnapp.risk.TraceLocationCheckInRisk
 import de.rki.coronawarnapp.risk.result.AggregatedRiskResult
 import de.rki.coronawarnapp.risk.storage.RiskLevelStorage
 import de.rki.coronawarnapp.server.protocols.internal.ppdd.PpaData
@@ -51,6 +52,8 @@ class ExposureRiskMetadataDonorTest : BaseTest() {
         override val exposureWindows: List<ExposureWindow>? = null
         override val matchedKeyCount: Int = 0
         override val daysWithEncounters: Int = 0
+        override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+            get() = emptyList() // todo
     }
 
     private fun createInstance() = ExposureRiskMetadataDonor(
diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt
index 9ec5698f0..7b2813947 100644
--- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt
+++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelChangeDetectorTest.kt
@@ -68,6 +68,8 @@ class RiskLevelChangeDetectorTest : BaseTest() {
         override val exposureWindows: List<ExposureWindow>? = null
         override val matchedKeyCount: Int = 0
         override val daysWithEncounters: Int = 0
+        override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+            get() = emptyList() // TODO
     }
 
     private fun createInstance(scope: CoroutineScope) = RiskLevelChangeDetector(
diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt
index 986a67bc7..61f5e691c 100644
--- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt
+++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultExtensionsTest.kt
@@ -22,10 +22,12 @@ class RiskLevelResultExtensionsTest : BaseTest() {
         override val exposureWindows: List<ExposureWindow>? = null
         override val matchedKeyCount: Int = 0
         override val daysWithEncounters: Int = 0
+        override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+            get() = emptyList() // TODO("Not yet implemented")
     }
 
     @Test
-    fun `getLastestAndLastSuccessful on empty results`() {
+    fun `getLatestAndLastSuccessful on empty results`() {
         val emptyResults = emptyList<RiskLevelResult>()
 
         emptyResults.tryLatestResultsWithDefaults().apply {
@@ -41,7 +43,7 @@ class RiskLevelResultExtensionsTest : BaseTest() {
     }
 
     @Test
-    fun `getLastestAndLastSuccessful last calculation was successful`() {
+    fun `getLatestAndLastSuccessful last calculation was successful`() {
         val results = listOf(
             createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH),
             createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH.plus(1))
@@ -54,7 +56,7 @@ class RiskLevelResultExtensionsTest : BaseTest() {
     }
 
     @Test
-    fun `getLastestAndLastSuccessful last calculation was not successful`() {
+    fun `getLatestAndLastSuccessful last calculation was not successful`() {
         val results = listOf(
             createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH),
             createRiskLevelResult(hasResult = true, calculatedAt = Instant.EPOCH.plus(1)),
@@ -68,7 +70,7 @@ class RiskLevelResultExtensionsTest : BaseTest() {
     }
 
     @Test
-    fun `getLastestAndLastSuccessful no successful calculations yet`() {
+    fun `getLatestAndLastSuccessful no successful calculations yet`() {
         val results = listOf(
             createRiskLevelResult(hasResult = false, calculatedAt = Instant.EPOCH.plus(10)),
             createRiskLevelResult(hasResult = false, calculatedAt = Instant.EPOCH.plus(11)),
diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt
index b40143539..27e93e671 100644
--- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt
+++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskLevelResultTest.kt
@@ -20,6 +20,8 @@ class RiskLevelResultTest : BaseTest() {
         override val exposureWindows: List<ExposureWindow>? = null
         override val matchedKeyCount: Int = 0
         override val daysWithEncounters: Int = 0
+        override val traceLocationCheckInRiskStates: List<TraceLocationCheckInRisk>
+            get() = emptyList() // TODO("Not yet implemented")
     }
 
     @Test
-- 
GitLab