From 52e1430383d22b409cf550f6c3647532793f4201 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Wed, 23 Jun 2021 17:00:06 +0200 Subject: [PATCH] Fix ppa test result (EXPOSUREAPP-7815) (#3528) * fix test result collection * fix test result collection * fix test Co-authored-by: BMItter <Berndus@gmx.de> Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com> --- .../coronatest/type/pcr/PCRTestProcessor.kt | 1 - .../type/rapidantigen/RATestProcessor.kt | 1 - .../AnalyticsTestResultCollector.kt | 33 +++------- .../testresult/AnalyticsTestResultDonor.kt | 12 ++-- .../testresult/AnalyticsTestResultSettings.kt | 6 +- .../coronatest/type/pcr/PCRProcessorTest.kt | 1 - .../type/rapidantigen/RAProcessorTest.kt | 1 - .../AnalyticsPCRTestResultDonorTest.kt | 16 ++--- .../AnalyticsRATestResultDonorTest.kt | 16 ++--- .../AnalyticsTestResultCollectorTest.kt | 66 ++++++++----------- 10 files changed, 61 insertions(+), 92 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRTestProcessor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRTestProcessor.kt index 78ecd61ad..034f4f47a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRTestProcessor.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRTestProcessor.kt @@ -116,7 +116,6 @@ class PCRTestProcessor @Inject constructor( // only collect for QR code test if (request is CoronaTestQRCode) { analyticsTestResultCollector.reportTestRegistered(type) - analyticsTestResultCollector.reportTestResultAtRegistration(testResult, type) analyticsTestResultCollector.reportTestResultReceived(testResult, type) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RATestProcessor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RATestProcessor.kt index 81b31698f..a88305c8a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RATestProcessor.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RATestProcessor.kt @@ -75,7 +75,6 @@ class RATestProcessor @Inject constructor( analyticsKeySubmissionCollector.reportPositiveTestResultReceived(type) } analyticsTestResultCollector.reportTestRegistered(type) - analyticsTestResultCollector.reportTestResultAtRegistration(testResult, type) analyticsTestResultCollector.reportTestResultReceived(testResult, type) val sampleCollectedAt = registrationData.testResultResponse.sampleCollectedAt diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollector.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollector.kt index c1ad9d98b..6ad128b7e 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollector.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollector.kt @@ -79,11 +79,17 @@ class AnalyticsTestResultCollector @Inject constructor( } } } + + type.settings.ewRiskLevelAtTestRegistration.update { + lastResult.ewRiskLevelResult.riskState.toMetadataRiskLevel() + } + type.settings.ptRiskLevelAtTestRegistration.update { + lastResult.ptRiskLevelResult.riskState.toMetadataRiskLevel() + } } - suspend fun reportTestResultAtRegistration(testResult: CoronaTestResult, type: CoronaTest.Type) { + fun reportTestResultReceived(testResult: CoronaTestResult, type: CoronaTest.Type) { if (analyticsDisabled) return - val validTestResults = when (type) { PCR -> listOf( CoronaTestResult.PCR_POSITIVE, @@ -99,32 +105,11 @@ class AnalyticsTestResultCollector @Inject constructor( if (testResult !in validTestResults) return // Not interested in other values - type.settings.testResultAtRegistration.update { testResult } + type.settings.testResult.update { testResult } if (testResult.isFinal) { type.settings.finalTestResultReceivedAt.update { timeStamper.nowUTC } } - - val lastRiskLevel = riskLevelStorage - .latestAndLastSuccessfulCombinedEwPtRiskLevelResult - .first() - .lastSuccessfullyCalculated - - type.settings.ewRiskLevelAtTestRegistration.update { - lastRiskLevel.ewRiskLevelResult.riskState.toMetadataRiskLevel() - } - type.settings.ptRiskLevelAtTestRegistration.update { - lastRiskLevel.ptRiskLevelResult.riskState.toMetadataRiskLevel() - } - } - - fun reportTestResultReceived(testResult: CoronaTestResult, type: CoronaTest.Type) { - if (analyticsDisabled) return - if (testResult.isFinal) { - val receivedAt = timeStamper.nowUTC - Timber.d("finalTestResultReceivedAt($testResult, $receivedAt)") - type.settings.finalTestResultReceivedAt.update { receivedAt } - } } /** diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultDonor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultDonor.kt index 33720b0c9..10514f111 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultDonor.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultDonor.kt @@ -43,8 +43,8 @@ abstract class AnalyticsTestResultDonor( return TestResultMetadataNoContribution } - val testResultAtRegistration = testResultSettings.testResultAtRegistration.value - if (testResultAtRegistration == null) { + val testResult = testResultSettings.testResult.value + if (testResult == null) { Timber.d("Skipping TestResultMetadata donation (testResultAtRegistration is missing)") return TestResultMetadataNoContribution } @@ -61,10 +61,10 @@ abstract class AnalyticsTestResultDonor( * it is included in the next submission and removed afterwards. * That means if the test result turns POS or NEG afterwards, this will not submitted */ - testResultAtRegistration.isPending && isDiffHoursMoreThanConfigHoursForPendingTest -> + testResult.isPending && isDiffHoursMoreThanConfigHoursForPendingTest -> pendingTestMetadataDonation( hoursSinceTestRegistrationTime = hoursSinceTestRegistrationTime, - testResult = testResultAtRegistration, + testResult = testResult, ) /** @@ -72,10 +72,10 @@ abstract class AnalyticsTestResultDonor( * it is included in the next submission. Afterwards, * the collected metric data is removed. */ - testResultAtRegistration.isFinal -> + testResult.isFinal -> finalTestMetadataDonation( timestampAtRegistration, - testResultAtRegistration, + testResult, ) else -> { Timber.d("Skipping Data donation") diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultSettings.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultSettings.kt index c0e24dd75..e333a3c16 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultSettings.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultSettings.kt @@ -82,8 +82,8 @@ open class AnalyticsTestResultSettings( } ) - val testResultAtRegistration = prefs.createFlowPreference( - key = PREFS_KEY_TEST_RESULT_AT_REGISTRATION + sharedPrefKeySuffix, + val testResult = prefs.createFlowPreference( + key = PREFS_KEY_TEST_RESULT + sharedPrefKeySuffix, reader = { key -> val value = getInt(key, -1) if (value == -1) { @@ -119,7 +119,7 @@ open class AnalyticsTestResultSettings( fun clear() = prefs.clearAndNotify() companion object { - private const val PREFS_KEY_TEST_RESULT_AT_REGISTRATION = "testResultDonor.testResultAtRegistration" + private const val PREFS_KEY_TEST_RESULT = "testResultDonor.testResultAtRegistration" // wrong name legacy private const val PREFS_KEY_RISK_LEVEL_AT_REGISTRATION_EW = "testResultDonor.riskLevelAtRegistration" private const val PREFS_KEY_RISK_LEVEL_AT_REGISTRATION_PT = "testResultDonor.ptRiskLevelAtRegistration" diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRProcessorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRProcessorTest.kt index d3de32a9c..0a6930376 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRProcessorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/pcr/PCRProcessorTest.kt @@ -91,7 +91,6 @@ class PCRProcessorTest : BaseTest() { } analyticsTestResultCollector.apply { coEvery { reportTestResultReceived(any(), any()) } just Runs - coEvery { reportTestResultAtRegistration(any(), PCR) } just Runs coEvery { reportTestRegistered(PCR) } just Runs coEvery { clear(PCR) } just Runs } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RAProcessorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RAProcessorTest.kt index 9a8114f0b..6f56c2e27 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RAProcessorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RAProcessorTest.kt @@ -92,7 +92,6 @@ class RAProcessorTest : BaseTest() { } analyticsTestResultCollector.apply { - coEvery { reportTestResultAtRegistration(any(), RAPID_ANTIGEN) } just Runs coEvery { reportTestResultReceived(any(), RAPID_ANTIGEN) } just Runs coEvery { reportTestRegistered(RAPID_ANTIGEN) } just Runs coEvery { clear(RAPID_ANTIGEN) } just Runs diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultDonorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultDonorTest.kt index c23987af9..b244e73a0 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultDonorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultDonorTest.kt @@ -65,20 +65,20 @@ class AnalyticsPCRTestResultDonorTest : BaseTest() { @Test fun `No donation when test result is INVALID`() = runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_INVALID) + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_INVALID) testResultDonor.beginDonation(TestRequest) shouldBe AnalyticsTestResultDonor.TestResultMetadataNoContribution } @Test fun `No donation when test result is REDEEMED`() = runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_REDEEMED) + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_REDEEMED) testResultDonor.beginDonation(TestRequest) shouldBe AnalyticsTestResultDonor.TestResultMetadataNoContribution } @Test fun `No donation when test result is PENDING and hours isn't greater or equal to config hours`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) testResultDonor.beginDonation(TestRequest) shouldBe @@ -89,7 +89,7 @@ class AnalyticsPCRTestResultDonorTest : BaseTest() { @Test fun `Donation is collected when test result is PENDING and hours is greater or equal to config hours`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) val timeDayBefore = baseTime.minus(Duration.standardDays(1)) every { testResultSettings.testRegisteredAt } returns mockFlowPreference(timeDayBefore) @@ -109,7 +109,7 @@ class AnalyticsPCRTestResultDonorTest : BaseTest() { @Test fun `Donation is collected when test result is POSITIVE`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_POSITIVE) every { testResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(baseTime) @@ -129,7 +129,7 @@ class AnalyticsPCRTestResultDonorTest : BaseTest() { @Test fun `Donation is collected when test result is NEGATIVE`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_NEGATIVE) every { testResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(baseTime) @@ -149,7 +149,7 @@ class AnalyticsPCRTestResultDonorTest : BaseTest() { @Test fun `Scenario 1 LowRisk`() = runBlockingTest { with(testResultSettings) { - every { testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_NEGATIVE) + every { testResult } returns mockFlowPreference(CoronaTestResult.PCR_NEGATIVE) every { finalTestResultReceivedAt } returns mockFlowPreference( Instant.parse("2021-03-20T20:00:00Z") ) @@ -174,7 +174,7 @@ class AnalyticsPCRTestResultDonorTest : BaseTest() { @Test fun `Scenario 2 HighRisk`() = runBlockingTest { with(testResultSettings) { - every { testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_POSITIVE) + every { testResult } returns mockFlowPreference(CoronaTestResult.PCR_POSITIVE) every { finalTestResultReceivedAt } returns mockFlowPreference( Instant.parse("2021-03-20T20:00:00Z") ) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsRATestResultDonorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsRATestResultDonorTest.kt index 5557a2ee4..e632bd633 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsRATestResultDonorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsRATestResultDonorTest.kt @@ -65,20 +65,20 @@ class AnalyticsRATestResultDonorTest : BaseTest() { @Test fun `No donation when test result is INVALID`() = runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.RAT_INVALID) + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.RAT_INVALID) testResultDonor.beginDonation(TestRequest) shouldBe AnalyticsTestResultDonor.TestResultMetadataNoContribution } @Test fun `No donation when test result is REDEEMED`() = runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.RAT_REDEEMED) + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.RAT_REDEEMED) testResultDonor.beginDonation(TestRequest) shouldBe AnalyticsTestResultDonor.TestResultMetadataNoContribution } @Test fun `No donation when test result is PENDING and hours isn't greater or equal to config hours`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) testResultDonor.beginDonation(TestRequest) shouldBe @@ -89,7 +89,7 @@ class AnalyticsRATestResultDonorTest : BaseTest() { @Test fun `Donation is collected when test result is PENDING and hours is greater or equal to config hours`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) val timeDayBefore = baseTime.minus(Duration.standardDays(1)) every { testResultSettings.testRegisteredAt } returns mockFlowPreference(timeDayBefore) @@ -109,7 +109,7 @@ class AnalyticsRATestResultDonorTest : BaseTest() { @Test fun `Donation is collected when test result is POSITIVE`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.RAT_POSITIVE) every { testResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(baseTime) @@ -128,7 +128,7 @@ class AnalyticsRATestResultDonorTest : BaseTest() { @Test fun `Donation is collected when test result is NEGATIVE`() { runBlockingTest { - every { testResultSettings.testResultAtRegistration } returns + every { testResultSettings.testResult } returns mockFlowPreference(CoronaTestResult.RAT_NEGATIVE) every { testResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(baseTime) @@ -147,7 +147,7 @@ class AnalyticsRATestResultDonorTest : BaseTest() { @Test fun `Scenario 1 LowRisk`() = runBlockingTest { with(testResultSettings) { - every { testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.RAT_NEGATIVE) + every { testResult } returns mockFlowPreference(CoronaTestResult.RAT_NEGATIVE) every { finalTestResultReceivedAt } returns mockFlowPreference( Instant.parse("2021-03-20T20:00:00Z") ) @@ -172,7 +172,7 @@ class AnalyticsRATestResultDonorTest : BaseTest() { @Test fun `Scenario 2 HighRisk`() = runBlockingTest { with(testResultSettings) { - every { testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.RAT_POSITIVE) + every { testResult } returns mockFlowPreference(CoronaTestResult.RAT_POSITIVE) every { finalTestResultReceivedAt } returns mockFlowPreference( Instant.parse("2021-03-20T20:00:00Z") ) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollectorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollectorTest.kt index 1b1a3ce4e..adf9a5439 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollectorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsTestResultCollectorTest.kt @@ -18,7 +18,6 @@ import de.rki.coronawarnapp.risk.EwRiskLevelResult import de.rki.coronawarnapp.risk.LastCombinedRiskResults import de.rki.coronawarnapp.risk.RiskState import de.rki.coronawarnapp.risk.storage.RiskLevelStorage -import de.rki.coronawarnapp.server.protocols.internal.ppdd.PpaData import de.rki.coronawarnapp.util.TimeStamper import io.mockk.Called import io.mockk.MockKAnnotations @@ -77,63 +76,52 @@ class AnalyticsTestResultCollectorTest : BaseTest() { fun `saveTestResultAnalyticsSettings does not save anything when no user consent`() = runBlockingTest { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(false) - analyticsTestResultCollector.reportTestResultAtRegistration(PCR_POSITIVE, PCR) + analyticsTestResultCollector.reportTestResultReceived(PCR_POSITIVE, PCR) verify(exactly = 0) { - pcrTestResultSettings.testResultAtRegistration - raTestResultSettings.testResultAtRegistration + pcrTestResultSettings.testResult + raTestResultSettings.testResult } - analyticsTestResultCollector.reportTestResultAtRegistration(RAT_POSITIVE, RAPID_ANTIGEN) + analyticsTestResultCollector.reportTestResultReceived(RAT_POSITIVE, RAPID_ANTIGEN) verify(exactly = 0) { - pcrTestResultSettings.testResultAtRegistration - raTestResultSettings.testResultAtRegistration + pcrTestResultSettings.testResult + raTestResultSettings.testResult } } @Test - fun `saveTestResultAtRegistration saves data when user gave consent`() = + fun `saveTestResult saves data when user gave consent`() = runBlockingTest { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(true) // PCR - every { pcrTestResultSettings.testResultAtRegistration } returns + every { pcrTestResultSettings.testResult } returns mockFlowPreference(null) every { pcrTestResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(Instant.EPOCH) - every { pcrTestResultSettings.ewRiskLevelAtTestRegistration } returns - mockFlowPreference(PpaData.PPARiskLevel.RISK_LEVEL_LOW) - every { pcrTestResultSettings.ptRiskLevelAtTestRegistration } returns - mockFlowPreference(PpaData.PPARiskLevel.RISK_LEVEL_LOW) - analyticsTestResultCollector.reportTestResultAtRegistration(PCR_POSITIVE, PCR) + analyticsTestResultCollector.reportTestResultReceived(PCR_POSITIVE, PCR) verify { analyticsSettings.analyticsEnabled - pcrTestResultSettings.testResultAtRegistration + pcrTestResultSettings.testResult pcrTestResultSettings.finalTestResultReceivedAt - pcrTestResultSettings.ewRiskLevelAtTestRegistration - pcrTestResultSettings.ptRiskLevelAtTestRegistration } // RAT - every { raTestResultSettings.testResultAtRegistration } returns + every { raTestResultSettings.testResult } returns mockFlowPreference(null) every { raTestResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(Instant.EPOCH) - every { raTestResultSettings.ewRiskLevelAtTestRegistration } returns - mockFlowPreference(PpaData.PPARiskLevel.RISK_LEVEL_LOW) - every { raTestResultSettings.ptRiskLevelAtTestRegistration } returns - mockFlowPreference(PpaData.PPARiskLevel.RISK_LEVEL_LOW) - analyticsTestResultCollector.reportTestResultAtRegistration(RAT_POSITIVE, RAPID_ANTIGEN) + analyticsTestResultCollector.reportTestResultReceived(RAT_POSITIVE, RAPID_ANTIGEN) verify { analyticsSettings.analyticsEnabled - raTestResultSettings.testResultAtRegistration + raTestResultSettings.testResult raTestResultSettings.finalTestResultReceivedAt - raTestResultSettings.ptRiskLevelAtTestRegistration } } @@ -141,8 +129,8 @@ class AnalyticsTestResultCollectorTest : BaseTest() { fun `saveTestResultAnalyticsSettings does not save data when TestResult is INVALID`() = runBlockingTest { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(false) - analyticsTestResultCollector.reportTestResultAtRegistration(PCR_INVALID, PCR) - analyticsTestResultCollector.reportTestResultAtRegistration(RAT_INVALID, RAPID_ANTIGEN) + analyticsTestResultCollector.reportTestResultReceived(PCR_INVALID, PCR) + analyticsTestResultCollector.reportTestResultReceived(RAT_INVALID, RAPID_ANTIGEN) verify { analyticsSettings.analyticsEnabled wasNot Called @@ -153,8 +141,8 @@ class AnalyticsTestResultCollectorTest : BaseTest() { fun `saveTestResultAnalyticsSettings does not save data when TestResult is REDEEMED`() = runBlockingTest { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(false) - analyticsTestResultCollector.reportTestResultAtRegistration(PCR_REDEEMED, PCR) - analyticsTestResultCollector.reportTestResultAtRegistration(RAT_REDEEMED, RAPID_ANTIGEN) + analyticsTestResultCollector.reportTestResultReceived(PCR_REDEEMED, PCR) + analyticsTestResultCollector.reportTestResultReceived(RAT_REDEEMED, RAPID_ANTIGEN) verify { analyticsSettings.analyticsEnabled wasNot Called } @@ -164,7 +152,7 @@ class AnalyticsTestResultCollectorTest : BaseTest() { fun `reportTestResultReceived doesn't update when TestResult isn't POS or NEG`() = runBlockingTest { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(true) - every { pcrTestResultSettings.testResultAtRegistration } returns mockFlowPreference( + every { pcrTestResultSettings.testResult } returns mockFlowPreference( PCR_OR_RAT_PENDING ) for (testResult in listOf(PCR_REDEEMED, PCR_INVALID, PCR_OR_RAT_PENDING)) { @@ -176,7 +164,7 @@ class AnalyticsTestResultCollectorTest : BaseTest() { } } - every { raTestResultSettings.testResultAtRegistration } returns mockFlowPreference( + every { raTestResultSettings.testResult } returns mockFlowPreference( PCR_OR_RAT_PENDING ) for (testResult in listOf(RAT_REDEEMED, RAT_INVALID, PCR_OR_RAT_PENDING)) { @@ -193,28 +181,28 @@ class AnalyticsTestResultCollectorTest : BaseTest() { fun `updatePendingTestResultReceivedTime doesn't update when Test is not scanned after consent`() = runBlockingTest { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(true) - every { pcrTestResultSettings.testResultAtRegistration } returns mockFlowPreference(PCR_OR_RAT_PENDING) + every { pcrTestResultSettings.testResult } returns mockFlowPreference(PCR_OR_RAT_PENDING) every { pcrTestResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(Instant.parse("2021-03-02T09:57:11+01:00")) analyticsTestResultCollector.reportTestResultReceived(PCR_NEGATIVE, PCR) verify { analyticsSettings.analyticsEnabled - pcrTestResultSettings.testResultAtRegistration wasNot Called + pcrTestResultSettings.testResult wasNot Called pcrTestResultSettings.finalTestResultReceivedAt wasNot Called - pcrTestResultSettings.testResultAtRegistration wasNot Called + pcrTestResultSettings.testResult wasNot Called } - every { raTestResultSettings.testResultAtRegistration } returns mockFlowPreference(PCR_OR_RAT_PENDING) + every { raTestResultSettings.testResult } returns mockFlowPreference(PCR_OR_RAT_PENDING) every { raTestResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(Instant.parse("2021-03-02T09:57:11+01:00")) analyticsTestResultCollector.reportTestResultReceived(RAT_NEGATIVE, RAPID_ANTIGEN) verify { analyticsSettings.analyticsEnabled - raTestResultSettings.testResultAtRegistration wasNot Called + raTestResultSettings.testResult wasNot Called raTestResultSettings.finalTestResultReceivedAt wasNot Called - raTestResultSettings.testResultAtRegistration wasNot Called + raTestResultSettings.testResult wasNot Called } } @@ -223,7 +211,7 @@ class AnalyticsTestResultCollectorTest : BaseTest() { runBlockingTest { for (testResult in listOf(PCR_NEGATIVE, PCR_POSITIVE)) { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(true) - every { pcrTestResultSettings.testResultAtRegistration } returns mockFlowPreference( + every { pcrTestResultSettings.testResult } returns mockFlowPreference( PCR_OR_RAT_PENDING ) every { pcrTestResultSettings.finalTestResultReceivedAt } returns @@ -239,7 +227,7 @@ class AnalyticsTestResultCollectorTest : BaseTest() { for (testResult in listOf(RAT_NEGATIVE, RAT_POSITIVE)) { every { analyticsSettings.analyticsEnabled } returns mockFlowPreference(true) - every { raTestResultSettings.testResultAtRegistration } returns mockFlowPreference( + every { raTestResultSettings.testResult } returns mockFlowPreference( PCR_OR_RAT_PENDING ) every { raTestResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(Instant.EPOCH) -- GitLab