Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Family Test Repository (EXPOSUREAPP-12330) (#4986)
Browse files Browse the repository at this point in the history
* data classes

* processor

* repo

* repo

* adapt polling

* klint/detekt

* klint/detekt

* klint

* add markViewed

* adapt naming

* fix labId logic

* make labId nonnull

* switch name

* fix assignment
  • Loading branch information
chiljamgossow authored Mar 24, 2022
1 parent f98c383 commit e02aa0b
Show file tree
Hide file tree
Showing 124 changed files with 942 additions and 562 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.coronatest.type.pcr.PCRCoronaTest
import de.rki.coronawarnapp.coronatest.type.rapidantigen.RACoronaTest
import de.rki.coronawarnapp.covidcertificate.common.certificate.DccV1
Expand All @@ -20,10 +20,10 @@ import de.rki.coronawarnapp.covidcertificate.common.repository.VaccinationCertif
import de.rki.coronawarnapp.covidcertificate.recovery.core.RecoveryCertificate
import de.rki.coronawarnapp.covidcertificate.test.core.TestCertificate
import de.rki.coronawarnapp.covidcertificate.vaccination.core.VaccinationCertificate
import de.rki.coronawarnapp.reyclebin.ui.adapter.CoronaTestCard
import de.rki.coronawarnapp.reyclebin.ui.adapter.OverviewSubHeaderItem
import de.rki.coronawarnapp.reyclebin.ui.adapter.RecoveryCertificateCard
import de.rki.coronawarnapp.reyclebin.ui.adapter.RecyclerBinItem
import de.rki.coronawarnapp.reyclebin.ui.adapter.CoronaTestCard
import de.rki.coronawarnapp.reyclebin.ui.adapter.TestCertificateCard
import de.rki.coronawarnapp.reyclebin.ui.adapter.VaccinationCertificateCard
import de.rki.coronawarnapp.util.TimeAndDateExtensions.toLocalDateUserTz
Expand Down Expand Up @@ -149,7 +149,7 @@ class RecyclerBinOverviewFragmentTest : BaseUITest() {
every { recycledAt } returns Instant.parse("2021-11-12T15:21:00.000Z")
}

private fun mockRATest(): CoronaTest =
private fun mockRATest(): BaseCoronaTest =
mockk<RACoronaTest> {
every { testTakenAt } returns Instant.parse("2021-06-01T11:35:00.000Z")
every { recycledAt } returns Instant.parse("2021-11-12T15:21:00.000Z")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.datadonation.analytics.modules.keysubmission.AnalyticsKeySubmissionCollector
import de.rki.coronawarnapp.submission.SubmissionRepository
import de.rki.coronawarnapp.submission.Symptoms
Expand Down Expand Up @@ -45,7 +45,7 @@ class SubmissionSymptomCalendarFragmentTest : BaseUITest() {
viewModel = spyk(
SubmissionSymptomCalendarViewModel(
Symptoms.Indication.POSITIVE,
CoronaTest.Type.PCR,
BaseCoronaTest.Type.PCR,
TestDispatcherProvider(),
submissionRepository,
autoSubmission,
Expand All @@ -59,7 +59,7 @@ class SubmissionSymptomCalendarFragmentTest : BaseUITest() {
object : SubmissionSymptomCalendarViewModel.Factory {
override fun create(
symptomIndication: Symptoms.Indication,
testType: CoronaTest.Type
testType: BaseCoronaTest.Type
): SubmissionSymptomCalendarViewModel = viewModel
}
)
Expand All @@ -76,7 +76,7 @@ class SubmissionSymptomCalendarFragmentTest : BaseUITest() {
launchFragmentInContainer2<SubmissionSymptomCalendarFragment>(
fragmentArgs = SubmissionSymptomCalendarFragmentArgs(
Symptoms.Indication.POSITIVE,
CoronaTest.Type.PCR
BaseCoronaTest.Type.PCR
).toBundle()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.datadonation.analytics.modules.keysubmission.AnalyticsKeySubmissionCollector
import de.rki.coronawarnapp.submission.SubmissionRepository
import de.rki.coronawarnapp.submission.Symptoms
Expand Down Expand Up @@ -50,15 +50,15 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() {
submissionRepository,
autoSubmission,
analyticsKeySubmissionCollector,
CoronaTest.Type.PCR
BaseCoronaTest.Type.PCR
)
)
with(viewModel) {
every { symptomIndication } returns MutableLiveData(Symptoms.Indication.POSITIVE)
}
setupMockViewModel(
object : SubmissionSymptomIntroductionViewModel.Factory {
override fun create(testType: CoronaTest.Type): SubmissionSymptomIntroductionViewModel = viewModel
override fun create(testType: BaseCoronaTest.Type): SubmissionSymptomIntroductionViewModel = viewModel
}
)
}
Expand All @@ -72,7 +72,7 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() {
fun launch_fragment() {
launchFragment2<SubmissionSymptomIntroductionFragment>(
fragmentArgs = SubmissionSymptomIntroductionFragmentArgs(
CoronaTest.Type.PCR
BaseCoronaTest.Type.PCR
).toBundle()
)
}
Expand All @@ -81,7 +81,7 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() {
fun testSymptomNextClicked() {
launchFragmentInContainer2<SubmissionSymptomIntroductionFragment>(
fragmentArgs = SubmissionSymptomIntroductionFragmentArgs(
CoronaTest.Type.PCR
BaseCoronaTest.Type.PCR
).toBundle()
)
onView(withId(R.id.symptom_button_next))
Expand All @@ -93,7 +93,7 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() {
fun capture_fragment() {
launchFragmentInContainer2<SubmissionSymptomIntroductionFragment>(
fragmentArgs = SubmissionSymptomIntroductionFragmentArgs(
CoronaTest.Type.PCR
BaseCoronaTest.Type.PCR
).toBundle()
)
takeScreenshot<SubmissionSymptomIntroductionFragment>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.datadonation.analytics.modules.keysubmission.AnalyticsKeySubmissionCollector
import de.rki.coronawarnapp.presencetracing.checkins.CheckInRepository
import de.rki.coronawarnapp.submission.SubmissionRepository
Expand Down Expand Up @@ -41,9 +41,9 @@ class SubmissionTestResultAvailableFragmentTest : BaseUITest() {
@MockK lateinit var appShortcutsHelper: AppShortcutsHelper
@MockK lateinit var analyticsKeySubmissionCollector: AnalyticsKeySubmissionCollector
@MockK lateinit var checkInRepository: CheckInRepository
@MockK lateinit var testType: CoronaTest.Type
@MockK lateinit var testType: BaseCoronaTest.Type
private val resultAvailableFragmentArgs =
SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle()
SubmissionTestResultConsentGivenFragmentArgs(testType = BaseCoronaTest.Type.PCR).toBundle()

@Before
fun setup() {
Expand All @@ -66,7 +66,7 @@ class SubmissionTestResultAvailableFragmentTest : BaseUITest() {

setupMockViewModel(
object : SubmissionTestResultAvailableViewModel.Factory {
override fun create(testType: CoronaTest.Type): SubmissionTestResultAvailableViewModel = viewModel
override fun create(testType: BaseCoronaTest.Type): SubmissionTestResultAvailableViewModel = viewModel
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.coronatest.server.CoronaTestResult
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.coronatest.type.PersonalCoronaTest
import de.rki.coronawarnapp.coronatest.type.pcr.notification.PCRTestResultAvailableNotificationService
import de.rki.coronawarnapp.datadonation.analytics.modules.keysubmission.AnalyticsKeySubmissionCollector
Expand Down Expand Up @@ -48,9 +48,9 @@ class SubmissionTestResultConsentGivenFragmentTest : BaseUITest() {
@MockK lateinit var autoSubmission: AutoSubmission
@MockK lateinit var testResultAvailableNotificationService: PCRTestResultAvailableNotificationService
@MockK lateinit var analyticsKeySubmissionCollector: AnalyticsKeySubmissionCollector
@MockK lateinit var testType: CoronaTest.Type
@MockK lateinit var testType: BaseCoronaTest.Type
private val consentGivenFragmentArgs =
SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle()
SubmissionTestResultConsentGivenFragmentArgs(testType = BaseCoronaTest.Type.PCR).toBundle()

private lateinit var viewModel: SubmissionTestResultConsentGivenViewModel

Expand All @@ -76,7 +76,7 @@ class SubmissionTestResultConsentGivenFragmentTest : BaseUITest() {
)
setupMockViewModel(
object : SubmissionTestResultConsentGivenViewModel.Factory {
override fun create(testType: CoronaTest.Type): SubmissionTestResultConsentGivenViewModel = viewModel
override fun create(testType: BaseCoronaTest.Type): SubmissionTestResultConsentGivenViewModel = viewModel
}
)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ class SubmissionTestResultConsentGivenFragmentTest : BaseUITest() {
coronaTest = mockk<PersonalCoronaTest>().apply {
every { testResult } returns CoronaTestResult.PCR_POSITIVE
every { registeredAt } returns Instant.now()
every { type } returns CoronaTest.Type.PCR
every { type } returns BaseCoronaTest.Type.PCR
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.coronatest.server.CoronaTestResult
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.coronatest.type.PersonalCoronaTest
import de.rki.coronawarnapp.coronatest.type.TestIdentifier
import de.rki.coronawarnapp.reyclebin.coronatest.RecycledCoronaTestsProvider
Expand Down Expand Up @@ -44,7 +44,7 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
@MockK lateinit var recycledTestProvider: RecycledCoronaTestsProvider

private val pendingFragmentArgs =
SubmissionTestResultPendingFragmentArgs(testType = CoronaTest.Type.PCR, testIdentifier = "").toBundle()
SubmissionTestResultPendingFragmentArgs(testType = BaseCoronaTest.Type.PCR, testIdentifier = "").toBundle()

@Before
fun setup() {
Expand All @@ -57,7 +57,7 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
TestDispatcherProvider(),
submissionRepository,
recycledTestProvider = recycledTestProvider,
testType = CoronaTest.Type.PCR,
testType = BaseCoronaTest.Type.PCR,
initialUpdate = false,
testIdentifier = ""
)
Expand All @@ -71,7 +71,7 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
every { testResult } returns CoronaTestResult.PCR_POSITIVE
every { registeredAt } returns Instant.now()
every { isProcessing } returns false
every { type } returns CoronaTest.Type.PCR
every { type } returns BaseCoronaTest.Type.PCR
}
)
)
Expand All @@ -80,7 +80,7 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
setupMockViewModel(
object : SubmissionTestResultPendingViewModel.Factory {
override fun create(
testType: CoronaTest.Type,
testType: BaseCoronaTest.Type,
testIdentifier: TestIdentifier,
initialUpdate: Boolean
): SubmissionTestResultPendingViewModel = viewModel
Expand Down Expand Up @@ -121,7 +121,7 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
every { testResult } returns CoronaTestResult.PCR_OR_RAT_PENDING
every { registeredAt } returns Instant.now()
every { isProcessing } returns false
every { type } returns CoronaTest.Type.PCR
every { type } returns BaseCoronaTest.Type.PCR
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.coronatest.server.CoronaTestResult
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.coronatest.type.TestIdentifier
import de.rki.coronawarnapp.coronatest.type.pcr.notification.PCRTestResultAvailableNotificationService
import de.rki.coronawarnapp.covidcertificate.ScreenshotCertificateTestData
Expand Down Expand Up @@ -47,10 +47,10 @@ class SubmissionTestResultNegativeFragmentTest : BaseUITest() {
@MockK lateinit var submissionRepository: SubmissionRepository
@MockK lateinit var certificateRepository: TestCertificateRepository
@MockK lateinit var testResultAvailableNotificationService: PCRTestResultAvailableNotificationService
@MockK lateinit var testType: CoronaTest.Type
@MockK lateinit var testType: BaseCoronaTest.Type
@MockK lateinit var recycledCoronaTestsProvider: RecycledCoronaTestsProvider
private val resultNegativeFragmentArgs =
SubmissionTestResultNegativeFragmentArgs(testType = CoronaTest.Type.PCR, testIdentifier = "").toBundle()
SubmissionTestResultNegativeFragmentArgs(testType = BaseCoronaTest.Type.PCR, testIdentifier = "").toBundle()

@Before
fun setup() {
Expand All @@ -74,7 +74,7 @@ class SubmissionTestResultNegativeFragmentTest : BaseUITest() {
setupMockViewModel(
object : SubmissionTestResultNegativeViewModel.Factory {
override fun create(
testType: CoronaTest.Type,
testType: BaseCoronaTest.Type,
testIdentifier: TestIdentifier
): SubmissionTestResultNegativeViewModel = viewModel
}
Expand All @@ -91,10 +91,10 @@ class SubmissionTestResultNegativeFragmentTest : BaseUITest() {
fun capture_fragment() {
every { viewModel.testResult } returns MutableLiveData(
SubmissionTestResultNegativeViewModel.UIState(
coronaTest = mockk<CoronaTest>().apply {
coronaTest = mockk<BaseCoronaTest>().apply {
every { testResult } returns CoronaTestResult.PCR_NEGATIVE
every { registeredAt } returns Instant.now()
every { type } returns CoronaTest.Type.PCR
every { type } returns BaseCoronaTest.Type.PCR
every { identifier } returns TestIdentifier()
},
certificateState = SubmissionTestResultNegativeViewModel.CertificateState.AVAILABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.coronatest.server.CoronaTestResult
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.coronatest.type.PersonalCoronaTest
import de.rki.coronawarnapp.coronatest.type.pcr.notification.PCRTestResultAvailableNotificationService
import de.rki.coronawarnapp.datadonation.analytics.modules.keysubmission.AnalyticsKeySubmissionCollector
Expand Down Expand Up @@ -36,9 +36,9 @@ class SubmissionTestResultNoConsentGivenFragmentTest : BaseUITest() {
@MockK lateinit var submissionRepository: SubmissionRepository
@MockK lateinit var testResultAvailableNotificationService: PCRTestResultAvailableNotificationService
@MockK lateinit var analyticsKeySubmissionCollector: AnalyticsKeySubmissionCollector
@MockK lateinit var testType: CoronaTest.Type
@MockK lateinit var testType: BaseCoronaTest.Type
private val noConsentGivenFragmentArgs =
SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle()
SubmissionTestResultConsentGivenFragmentArgs(testType = BaseCoronaTest.Type.PCR).toBundle()

private lateinit var viewModel: SubmissionTestResultNoConsentViewModel

Expand All @@ -57,7 +57,7 @@ class SubmissionTestResultNoConsentGivenFragmentTest : BaseUITest() {
)
setupMockViewModel(
object : SubmissionTestResultNoConsentViewModel.Factory {
override fun create(testType: CoronaTest.Type): SubmissionTestResultNoConsentViewModel = viewModel
override fun create(testType: BaseCoronaTest.Type): SubmissionTestResultNoConsentViewModel = viewModel
}
)
}
Expand All @@ -75,7 +75,7 @@ class SubmissionTestResultNoConsentGivenFragmentTest : BaseUITest() {
coronaTest = mockk<PersonalCoronaTest>().apply {
every { testResult } returns CoronaTestResult.PCR_POSITIVE
every { registeredAt } returns Instant.now()
every { type } returns CoronaTest.Type.PCR
every { type } returns BaseCoronaTest.Type.PCR
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package de.rki.coronawarnapp.ui.submission
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.Module
import dagger.android.ContributesAndroidInjector
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.storage.interoperability.InteroperabilityRepository
import de.rki.coronawarnapp.submission.SubmissionRepository
import de.rki.coronawarnapp.ui.submission.yourconsent.SubmissionYourConsentFragment
Expand All @@ -28,7 +28,7 @@ class SubmissionYourConsentFragmentTest : BaseUITest() {

@MockK lateinit var submissionRepository: SubmissionRepository
@MockK lateinit var interoperabilityRepository: InteroperabilityRepository
val testType = CoronaTest.Type.PCR
val testType = BaseCoronaTest.Type.PCR

private lateinit var viewModel: SubmissionYourConsentViewModel

Expand All @@ -45,7 +45,7 @@ class SubmissionYourConsentFragmentTest : BaseUITest() {
)
setupMockViewModel(
object : SubmissionYourConsentViewModel.Factory {
override fun create(testType: CoronaTest.Type): SubmissionYourConsentViewModel = viewModel
override fun create(testType: BaseCoronaTest.Type): SubmissionYourConsentViewModel = viewModel
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import de.rki.coronawarnapp.bugreporting.debuglog.internal.DebuggerScope
import de.rki.coronawarnapp.contactdiary.storage.entity.ContactDiaryCoronaTestEntity
import de.rki.coronawarnapp.contactdiary.storage.repo.ContactDiaryRepository
import de.rki.coronawarnapp.coronatest.CoronaTestRepository
import de.rki.coronawarnapp.coronatest.type.CoronaTest
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
Expand Down Expand Up @@ -40,7 +40,7 @@ class CoronaTestCensor @Inject constructor(
mutex.withLock {
tests.forEach { test ->
when (test) {
is CoronaTest -> {
is BaseCoronaTest -> {
// The Registration Token is received after registration of PCR and RAT tests. It is required to poll the test result.
tokenHistory.add(test.registrationToken)
identifierHistory.add(test.identifier)
Expand Down
Loading

0 comments on commit e02aa0b

Please sign in to comment.