From 0f4b824a2227a7fb1146c7b8c709db48216d2f7b Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli <mohamed.metwalli@sap.com> Date: Fri, 28 May 2021 13:02:05 +0200 Subject: [PATCH] Migrate from build dependency on jcenter (EXPOSUREAPP-7437) (#3272) * Phase 1 * Phase 2 * Fix test * Phase 3 * Update ContactDiaryDayFragmentTest.kt * Tests refactoring * Lint * Fix tests * lint * Revert * Run screenshots * Revert screenshots Co-authored-by: Matthias Urhahn <matthias.urhahn@sap.com> --- Corona-Warn-App/build.gradle | 5 +- .../bugreporting/DebugLogFragmentTest.kt | 10 -- .../DebugLogUploadFragmentTest.kt | 10 -- .../ContactDiaryDayFragmentTest.kt | 13 +-- .../ContactDiaryEditLocationsFragmentTest.kt | 10 -- .../ContactDiaryEditPersonsFragmentTest.kt | 10 -- ...tactDiaryInformationPrivacyFragmentTest.kt | 12 +-- .../ContactDiaryOnboardingFragmentTest.kt | 9 -- .../ContactDiaryOverviewFragmentTest.kt | 34 +------ .../ui/main/home/HomeFragmentTest.kt | 72 +------------- .../OnboardingAnalyticsFragmentTest.kt | 10 -- ...ardingDeltaInteroperabilityFragmentTest.kt | 10 -- .../ui/onboarding/OnboardingFragmentTest.kt | 10 -- .../OnboardingNotificationsFragmentTest.kt | 10 -- .../OnboardingPrivacyFragmentTest.kt | 10 -- .../onboarding/OnboardingTestFragmentTest.kt | 10 -- .../OnboardingTracingFragmentTest.kt | 10 -- .../ui/statistics/StatisticsCardsTest.kt | 1 - .../StatisticsExplanationFragmentTest.kt | 10 -- .../SubmissionConsentFragmentTest.kt | 10 -- .../SubmissionContactFragmentTest.kt | 10 -- .../SubmissionDispatcherFragmentTest.kt | 10 -- .../SubmissionSymptomCalendarFragmentTest.kt | 10 -- .../SubmissionSymptomIntroFragmentTest.kt | 10 -- .../submission/SubmissionTanFragmentTest.kt | 10 -- ...bmissionTestResultAvailableFragmentTest.kt | 10 -- ...ssionTestResultConsentGivenFragmentTest.kt | 10 -- .../SubmissionTestResultFragmentTest.kt | 10 -- ...ubmissionTestResultNegativeFragmentTest.kt | 10 -- ...ionTestResultNoConsentGivenFragmentTest.kt | 10 -- .../SubmissionYourConsentFragmentTest.kt | 10 -- .../ui/tracing/TracingDetailsFragmentTest.kt | 10 -- .../VaccinationConsentFragmentTest.kt | 9 -- .../details/VaccinationDetailsFragmentTest.kt | 10 -- .../ui/list/VaccinationListFragmentTest.kt | 10 -- .../java/testhelpers/BaseUITest.kt | 3 + .../java/testhelpers/ScreenShotter.kt | 19 ++-- .../keydownload/ui/KeyFileDownloadAdapter.kt | 6 +- .../test/submission/ui/TEKHistoryAdapter.kt | 6 +- ...posureWindowRiskCalculationConfigMapper.kt | 4 +- .../exception/http/CwaWebException.kt | 8 +- .../exception/reporting/ReportedException.kt | 12 +-- .../storage/InsufficientStorageException.kt | 4 +- .../fallback/DefaultAppConfigSourceTest.kt | 3 +- .../censors/CoronaTestCensorTest.kt | 1 + .../censors/DiaryLocationCensorTest.kt | 1 + .../censors/RACoronaTestCensorTest.kt | 1 + .../censors/RatQrCodeCensorTest.kt | 1 + .../censors/TraceLocationCensorTest.kt | 1 + .../submission/RatProfileCensorTest.kt | 1 + .../CertificateQrCodeCensorTest.kt | 1 + .../internal/DebugLogStorageCheckTest.kt | 5 - .../ui/ContactDiarySettingsTest.kt | 5 +- .../ContactDiaryEditLocationsViewModelTest.kt | 7 +- .../ContactDiaryEditPersonsViewModelTest.kt | 7 +- .../ui/exporter/ContactDiaryExporterTest.kt | 25 ++--- .../ContactDiaryOverviewViewModelTest.kt | 16 +-- .../util/ContactDiaryExportStringsMock.kt | 10 +- .../coronatest/qrcode/TestQrCodes.kt | 43 +++++--- .../AnalyticsExposureWindowDonorTest.kt | 4 +- .../testresult/AnalyticsPCRTestResultTest.kt | 15 ++- .../survey/SurveyUrlProviderTest.kt | 6 +- .../datadonation/survey/SurveysTest.kt | 2 +- .../download/HourPackageSyncToolTest.kt | 33 ++++--- .../ExposureDetectionTrackerExtensionsTest.kt | 5 - .../DefaultDiagnosisKeyProviderTest.kt | 3 +- .../DefaultTEKHistoryProviderTest.kt | 6 +- .../tracing/DefaultTracingStatusTest.kt | 4 - .../windows/ExposureWindowsCalculationTest.kt | 98 ++++++++++++------- .../checkins/common/CheckInExtensionTest.kt | 3 +- .../checkins/qrcode/Base32UrlProvider.kt | 1 + .../checkins/qrcode/Base64UrlProvider.kt | 8 +- .../server/QrCodePosterTemplateServerTest.kt | 31 +++--- .../calculation/CheckInWarningMatcherTest.kt | 2 + .../PresenceTracingRiskRepositoryTest.kt | 7 +- .../risk/storage/BaseRiskLevelStorageTest.kt | 9 +- .../internal/PersistedRiskResultDaoTest.kt | 6 +- .../statistics/source/StatisticsServerTest.kt | 40 ++++---- .../ui/settings/TracingSettingsStateTest.kt | 12 ++- .../start/SettingsTracingStateTest.kt | 12 ++- .../scan/SubmissionQRCodeScanViewModelTest.kt | 8 +- .../util/NoPaddingTestProvider.kt | 1 + .../coronawarnapp/util/RetryMechanismTest.kt | 1 + .../util/WithPaddingTestProvider.kt | 2 +- .../FormatterSubmissionHelperTest.kt | 46 ++++++--- .../util/network/NetworkStateProviderTest.kt | 4 +- .../util/worker/WorkerBinderTest.kt | 3 +- .../vaccination/core/VaccinationTestData.kt | 1 + .../server/valueset/VaccinationServerTest.kt | 1 + .../src/test/java/testhelpers/BaseTest.kt | 1 + .../testhelpers/gms/MockListenableFuture.kt | 2 - .../ExposureWindowProviderTest.kt | 2 +- build.gradle | 8 +- 93 files changed, 349 insertions(+), 653 deletions(-) delete mode 100644 Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsCardsTest.kt diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle index 06191fd03..f1ce04d22 100644 --- a/Corona-Warn-App/build.gradle +++ b/Corona-Warn-App/build.gradle @@ -358,7 +358,7 @@ dependencies { testImplementation('org.robolectric:robolectric:4.5.1') { exclude group: 'com.google.protobuf' } - testImplementation "io.mockk:mockk:1.10.4" + testImplementation "io.mockk:mockk:1.11.0" testImplementation "com.squareup.okhttp3:mockwebserver:4.9.0" testImplementation 'org.hamcrest:hamcrest-library:2.2' @@ -391,11 +391,10 @@ dependencies { androidTestImplementation 'androidx.test:rules:1.3.0' androidTestImplementation 'androidx.test.ext:truth:1.3.0' androidTestImplementation 'androidx.work:work-testing:2.5.0' - androidTestImplementation "io.mockk:mockk-android:1.10.4" + androidTestImplementation "io.mockk:mockk-android:1.11.0" debugImplementation 'androidx.fragment:fragment-testing:1.2.5' debugImplementation 'androidx.test:core-ktx:1.3.0' - androidTestImplementation 'tools.fastlane:screengrab:2.0.0' androidTestImplementation "androidx.navigation:navigation-testing:$nav_version" // Play Services diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogFragmentTest.kt index c18496b74..90b342355 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogFragmentTest.kt @@ -15,17 +15,14 @@ import io.mockk.impl.annotations.MockK import io.mockk.spyk import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class DebugLogFragmentTest : BaseUITest() { @@ -38,13 +35,6 @@ class DebugLogFragmentTest : BaseUITest() { private lateinit var inactiveViewModel: DebugLogViewModel private lateinit var activeViewModel: DebugLogViewModel - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogUploadFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogUploadFragmentTest.kt index a093866ea..bb92eab6c 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogUploadFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/bugreporting/DebugLogUploadFragmentTest.kt @@ -11,30 +11,20 @@ import io.mockk.impl.annotations.MockK import io.mockk.spyk import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class DebugLogUploadFragmentTest : BaseUITest() { @MockK lateinit var snapShotUploader: SnapshotUploader - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: DebugLogUploadViewModel @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt index cc57ba6db..6fda25cb9 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryDayFragmentTest.kt @@ -28,31 +28,20 @@ import kotlinx.coroutines.test.TestCoroutineScope import org.joda.time.LocalDate import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.selectTabAtPosition import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule -import tools.fastlane.screengrab.locale.LocaleUtil import java.util.Locale @RunWith(AndroidJUnit4::class) class ContactDiaryDayFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @MockK lateinit var contactDiaryRepository: ContactDiaryRepository private lateinit var viewModel: ContactDiaryDayViewModel @@ -69,7 +58,7 @@ class ContactDiaryDayFragmentTest : BaseUITest() { every { viewModel.uiState } returns MutableLiveData( ContactDiaryDayViewModel.UIState( - dayText = { LocalDate.now().toFormattedDay(LocaleUtil.getTestLocale() ?: Locale.getDefault()) }, + dayText = { LocalDate.now().toFormattedDay(Locale.getDefault()) }, dayTextContentDescription = { "Description" } ) ) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt index 7bb0ecd50..33e5fa12b 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditLocationsFragmentTest.kt @@ -15,28 +15,18 @@ import io.mockk.spyk import kotlinx.coroutines.test.TestCoroutineScope import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class ContactDiaryEditLocationsFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @MockK lateinit var contactDiaryRepository: ContactDiaryRepository private lateinit var viewModel: ContactDiaryEditLocationsViewModel diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt index 1e80c7199..cfa9ad230 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryEditPersonsFragmentTest.kt @@ -15,28 +15,18 @@ import io.mockk.spyk import kotlinx.coroutines.test.TestCoroutineScope import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class ContactDiaryEditPersonsFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @MockK lateinit var contactDiaryRepository: ContactDiaryRepository private lateinit var viewModel: ContactDiaryEditPersonsViewModel diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt index 450d89231..f2820196f 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryInformationPrivacyFragmentTest.kt @@ -2,24 +2,16 @@ package de.rki.coronawarnapp.ui.contactdiary import androidx.test.ext.junit.runners.AndroidJUnit4 import de.rki.coronawarnapp.ui.information.InformationPrivacyFragment -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import testhelpers.BaseUITest import testhelpers.takeScreenshot import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) -class ContactDiaryInformationPrivacyFragmentTest { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() +class ContactDiaryInformationPrivacyFragmentTest : BaseUITest() { @Test fun launch_fragment() { diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt index d1e4a35c6..d43c19259 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOnboardingFragmentTest.kt @@ -9,25 +9,16 @@ import de.rki.coronawarnapp.contactdiary.ui.onboarding.ContactDiaryOnboardingFra import io.mockk.MockKAnnotations import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class ContactDiaryOnboardingFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() private val fragmentArgs = ContactDiaryOnboardingFragmentArgs( showBottomNav = false diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt index 6308bfb83..888c57eea 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/contactdiary/ContactDiaryOverviewFragmentTest.kt @@ -8,32 +8,22 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import dagger.Module import dagger.android.ContributesAndroidInjector import de.rki.coronawarnapp.R -import de.rki.coronawarnapp.contactdiary.storage.repo.ContactDiaryRepository -import de.rki.coronawarnapp.contactdiary.ui.exporter.ContactDiaryExporter import de.rki.coronawarnapp.contactdiary.ui.overview.ContactDiaryOverviewFragment import de.rki.coronawarnapp.contactdiary.ui.overview.ContactDiaryOverviewViewModel import de.rki.coronawarnapp.contactdiary.ui.overview.adapter.DiaryOverviewItem import de.rki.coronawarnapp.contactdiary.ui.overview.adapter.day.DayOverviewItem import de.rki.coronawarnapp.contactdiary.ui.overview.adapter.day.contact.ContactItem import de.rki.coronawarnapp.contactdiary.ui.overview.adapter.subheader.OverviewSubHeaderItem -import de.rki.coronawarnapp.presencetracing.checkins.CheckInRepository -import de.rki.coronawarnapp.risk.storage.RiskLevelStorage -import de.rki.coronawarnapp.task.TaskController -import de.rki.coronawarnapp.util.TimeStamper import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.MockK -import io.mockk.spyk import org.joda.time.LocalDate import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule -import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchInMainActivity import testhelpers.recyclerScrollTo @@ -43,33 +33,11 @@ import testhelpers.takeScreenshot @RunWith(AndroidJUnit4::class) class ContactDiaryOverviewFragmentTest : BaseUITest() { - @MockK lateinit var taskController: TaskController - @MockK lateinit var contactDiaryRepository: ContactDiaryRepository - @MockK lateinit var riskLevelStorage: RiskLevelStorage - @MockK lateinit var timeStamper: TimeStamper - @MockK lateinit var exporter: ContactDiaryExporter - @MockK lateinit var checkInRepository: CheckInRepository - - private lateinit var viewModel: ContactDiaryOverviewViewModel - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() + @MockK lateinit var viewModel: ContactDiaryOverviewViewModel @Before fun setup() { MockKAnnotations.init(this, relaxed = true) - viewModel = spyk( - ContactDiaryOverviewViewModel( - taskController = taskController, - dispatcherProvider = TestDispatcherProvider(), - contactDiaryRepository = contactDiaryRepository, - riskLevelStorage = riskLevelStorage, - timeStamper = timeStamper, - checkInRepository = checkInRepository, - exporter = exporter - ) - ) - setupMockViewModel( object : ContactDiaryOverviewViewModel.Factory { override fun create(): ContactDiaryOverviewViewModel = viewModel diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt index ddff5cccc..3c4c0e9cf 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentTest.kt @@ -8,34 +8,18 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import dagger.Module import dagger.android.ContributesAndroidInjector import de.rki.coronawarnapp.R -import de.rki.coronawarnapp.appconfig.AppConfigProvider -import de.rki.coronawarnapp.coronatest.CoronaTestRepository -import de.rki.coronawarnapp.main.CWASettings -import de.rki.coronawarnapp.statistics.source.StatisticsProvider import de.rki.coronawarnapp.statistics.ui.homecards.StatisticsHomeCard -import de.rki.coronawarnapp.storage.TracingRepository -import de.rki.coronawarnapp.storage.TracingSettings -import de.rki.coronawarnapp.submission.SubmissionRepository import de.rki.coronawarnapp.submission.ui.homecards.PcrTestPositiveCard import de.rki.coronawarnapp.submission.ui.homecards.PcrTestSubmissionDoneCard import de.rki.coronawarnapp.submission.ui.homecards.RapidTestPositiveCard import de.rki.coronawarnapp.submission.ui.homecards.RapidTestSubmissionDoneCard import de.rki.coronawarnapp.submission.ui.homecards.TestResultItem -import de.rki.coronawarnapp.tracing.GeneralTracingStatus -import de.rki.coronawarnapp.tracing.states.TracingStateProvider import de.rki.coronawarnapp.tracing.ui.homecards.TracingStateItem import de.rki.coronawarnapp.tracing.ui.statusbar.TracingHeaderState import de.rki.coronawarnapp.ui.main.home.items.FAQCard import de.rki.coronawarnapp.ui.main.home.items.HomeItem -import de.rki.coronawarnapp.ui.presencetracing.organizer.TraceLocationOrganizerSettings import de.rki.coronawarnapp.ui.statistics.Statistics -import de.rki.coronawarnapp.util.TimeStamper -import de.rki.coronawarnapp.util.bluetooth.BluetoothSupport -import de.rki.coronawarnapp.util.encryptionmigration.EncryptionErrorResetTool -import de.rki.coronawarnapp.util.shortcuts.AppShortcutsHelper import de.rki.coronawarnapp.util.ui.SingleLiveEvent -import de.rki.coronawarnapp.vaccination.core.VaccinationSettings -import de.rki.coronawarnapp.vaccination.core.repository.VaccinationRepository import de.rki.coronawarnapp.vaccination.ui.homecard.CreateVaccinationHomeCard import de.rki.coronawarnapp.vaccination.ui.homecard.VaccinationStatusItem import io.mockk.MockKAnnotations @@ -43,17 +27,13 @@ import io.mockk.Runs import io.mockk.every import io.mockk.impl.annotations.MockK import io.mockk.just -import io.mockk.spyk import io.mockk.verify import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule -import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchInMainActivity import testhelpers.recyclerScrollTo @@ -63,32 +43,11 @@ import timber.log.Timber @RunWith(AndroidJUnit4::class) class HomeFragmentTest : BaseUITest() { - @MockK lateinit var errorResetTool: EncryptionErrorResetTool - @MockK lateinit var tracingStatus: GeneralTracingStatus - @MockK lateinit var tracingStateProviderFactory: TracingStateProvider.Factory - @MockK lateinit var coronaTestRepository: CoronaTestRepository - @MockK lateinit var tracingRepository: TracingRepository - @MockK lateinit var submissionRepository: SubmissionRepository - @MockK lateinit var cwaSettings: CWASettings - @MockK lateinit var appConfigProvider: AppConfigProvider - @MockK lateinit var statisticsProvider: StatisticsProvider - @MockK lateinit var appShortcutsHelper: AppShortcutsHelper - @MockK lateinit var tracingSettings: TracingSettings - @MockK lateinit var vaccinationSettings: VaccinationSettings - @MockK lateinit var traceLocationOrganizerSettings: TraceLocationOrganizerSettings - @MockK lateinit var timeStamper: TimeStamper - @MockK lateinit var bluetoothSupport: BluetoothSupport - @MockK lateinit var vaccinationRepository: VaccinationRepository - - private lateinit var homeFragmentViewModel: HomeFragmentViewModel - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() + @MockK lateinit var homeFragmentViewModel: HomeFragmentViewModel @Before fun setup() { MockKAnnotations.init(this, relaxed = true) - homeFragmentViewModel = homeFragmentViewModelSpy() with(homeFragmentViewModel) { every { refreshRequiredData() } just Runs every { tracingHeaderState } returns MutableLiveData(TracingHeaderState.TracingActive) @@ -104,9 +63,6 @@ class HomeFragmentTest : BaseUITest() { override fun create(): HomeFragmentViewModel = homeFragmentViewModel } ) - - every { bluetoothSupport.isScanningSupported } returns true - every { bluetoothSupport.isAdvertisingSupported } returns true } @Screenshot @@ -271,8 +227,6 @@ class HomeFragmentTest : BaseUITest() { fun captureHomeFragmentCompatibilityBleBroadcastNotSupported() { every { homeFragmentViewModel.homeItems } returns homeFragmentItemsLiveData(HomeData.Tracing.TRACING_FAILED_ITEM) - every { bluetoothSupport.isScanningSupported } returns true - every { bluetoothSupport.isAdvertisingSupported } returns false launchInMainActivity<HomeFragment>() onView(withId(R.id.recycler_view)).perform(recyclerScrollTo(2)) captureHomeFragment("compatibility_ble_broadcast_not_supported") @@ -283,8 +237,6 @@ class HomeFragmentTest : BaseUITest() { fun captureHomeFragmentCompatibilityBleScanNotSupported() { every { homeFragmentViewModel.homeItems } returns homeFragmentItemsLiveData(HomeData.Tracing.TRACING_FAILED_ITEM) - every { bluetoothSupport.isScanningSupported } returns false - every { bluetoothSupport.isAdvertisingSupported } returns true launchInMainActivity<HomeFragment>() onView(withId(R.id.recycler_view)).perform(recyclerScrollTo(2)) captureHomeFragment("compatibility_ble_scan_not_supported") @@ -351,28 +303,6 @@ class HomeFragmentTest : BaseUITest() { takeScreenshot<HomeFragment>(nameSuffix) } - private fun homeFragmentViewModelSpy() = spyk( - HomeFragmentViewModel( - dispatcherProvider = TestDispatcherProvider(), - errorResetTool = errorResetTool, - tracingRepository = tracingRepository, - tracingStateProviderFactory = tracingStateProviderFactory, - appConfigProvider = appConfigProvider, - tracingStatus = tracingStatus, - submissionRepository = submissionRepository, - coronaTestRepository = coronaTestRepository, - cwaSettings = cwaSettings, - statisticsProvider = statisticsProvider, - appShortcutsHelper = appShortcutsHelper, - tracingSettings = tracingSettings, - traceLocationOrganizerSettings = traceLocationOrganizerSettings, - timeStamper = timeStamper, - bluetoothSupport = bluetoothSupport, - vaccinationSettings = vaccinationSettings, - vaccinationRepository = vaccinationRepository - ) - ) - // LiveData item for fragments private fun homeFragmentItemsLiveData( tracingStateItem: TracingStateItem = HomeData.Tracing.LOW_RISK_ITEM_WITH_ENCOUNTERS, diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsFragmentTest.kt index 634908d8b..bf3d78db5 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsFragmentTest.kt @@ -18,16 +18,13 @@ import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOf import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot import testhelpers.launchFragment2 -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingAnalyticsFragmentTest : BaseUITest() { @@ -38,13 +35,6 @@ class OnboardingAnalyticsFragmentTest : BaseUITest() { private lateinit var viewModel: OnboardingAnalyticsViewModel - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingDeltaInteroperabilityFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingDeltaInteroperabilityFragmentTest.kt index 0b32b217d..59aa5218a 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingDeltaInteroperabilityFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingDeltaInteroperabilityFragmentTest.kt @@ -8,30 +8,20 @@ import io.mockk.MockKAnnotations import io.mockk.impl.annotations.MockK import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingDeltaInteroperabilityFragmentTest : BaseUITest() { @MockK lateinit var interopRepo: InteroperabilityRepository - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt index 37e5a4d49..f44312b0a 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingFragmentTest.kt @@ -7,27 +7,17 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import dagger.Module import dagger.android.ContributesAndroidInjector import de.rki.coronawarnapp.R -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Test fun launch_fragment() { launchFragment2<OnboardingFragment>() diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragmentTest.kt index 1954b667c..696b42d00 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragmentTest.kt @@ -5,27 +5,17 @@ import dagger.Module import dagger.android.ContributesAndroidInjector import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingNotificationsFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { setupMockViewModel( diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingPrivacyFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingPrivacyFragmentTest.kt index 96af67c85..9f8e3c322 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingPrivacyFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingPrivacyFragmentTest.kt @@ -5,27 +5,17 @@ import dagger.Module import dagger.android.ContributesAndroidInjector import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingPrivacyFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { setupMockViewModel( diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTestFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTestFragmentTest.kt index 3d07dec0f..60a2b5504 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTestFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTestFragmentTest.kt @@ -5,27 +5,17 @@ import dagger.Module import dagger.android.ContributesAndroidInjector import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingTestFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { setupMockViewModel( diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragmentTest.kt index 61922e752..6982b0472 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragmentTest.kt @@ -16,17 +16,14 @@ import io.mockk.spyk import kotlinx.coroutines.flow.flowOf import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class OnboardingTracingFragmentTest : BaseUITest() { @@ -36,13 +33,6 @@ class OnboardingTracingFragmentTest : BaseUITest() { @MockK lateinit var tracingSettings: TracingSettings @MockK lateinit var enfClient: ENFClient - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsCardsTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsCardsTest.kt deleted file mode 100644 index 8b1378917..000000000 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsCardsTest.kt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsExplanationFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsExplanationFragmentTest.kt index 7553d59da..479ac33d7 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsExplanationFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/statistics/StatisticsExplanationFragmentTest.kt @@ -4,25 +4,15 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import dagger.Module import dagger.android.ContributesAndroidInjector import de.rki.coronawarnapp.statistics.ui.StatisticsExplanationFragment -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.captureScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class StatisticsExplanationFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Screenshot @Test fun capture_screenshot() { diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionConsentFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionConsentFragmentTest.kt index 787e0d2ed..0bd7d1229 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionConsentFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionConsentFragmentTest.kt @@ -17,15 +17,12 @@ import io.mockk.impl.annotations.MockK import kotlinx.coroutines.flow.flowOf import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionConsentFragmentTest : BaseUITest() { @@ -36,13 +33,6 @@ class SubmissionConsentFragmentTest : BaseUITest() { @MockK lateinit var qrCodeRegistrationStateProcessor: QrCodeRegistrationStateProcessor @MockK lateinit var qrCodeValidator: CoronaTestQrCodeValidator - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: SubmissionConsentViewModel private val fragmentArgs = SubmissionConsentFragmentArgs( diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionContactFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionContactFragmentTest.kt index ac04a0a70..66084e47a 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionContactFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionContactFragmentTest.kt @@ -16,27 +16,17 @@ import de.rki.coronawarnapp.ui.submission.viewmodel.SubmissionContactViewModel import io.mockk.MockKAnnotations import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.captureScreenshot import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionContactFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private fun createViewModel() = SubmissionContactViewModel() @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionDispatcherFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionDispatcherFragmentTest.kt index 3b63821e0..8ae2f06dd 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionDispatcherFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionDispatcherFragmentTest.kt @@ -20,30 +20,20 @@ import io.mockk.every import io.mockk.impl.annotations.MockK import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.preferences.mockFlowPreference import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionDispatcherFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @MockK lateinit var ratProfileSettings: RATProfileSettings private fun createViewModel() = SubmissionDispatcherViewModel( diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomCalendarFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomCalendarFragmentTest.kt index f80a5891d..5c252adb0 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomCalendarFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomCalendarFragmentTest.kt @@ -22,16 +22,13 @@ import io.mockk.impl.annotations.MockK import io.mockk.spyk import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionSymptomCalendarFragmentTest : BaseUITest() { @@ -40,13 +37,6 @@ class SubmissionSymptomCalendarFragmentTest : BaseUITest() { @MockK lateinit var autoSubmission: AutoSubmission @MockK lateinit var analyticsKeySubmissionCollector: AnalyticsKeySubmissionCollector - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: SubmissionSymptomCalendarViewModel @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt index eea3e2c46..dce082f74 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt @@ -23,18 +23,15 @@ import io.mockk.impl.annotations.MockK import io.mockk.spyk import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionSymptomIntroFragmentTest : BaseUITest() { @@ -43,13 +40,6 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() { @MockK lateinit var autoSubmission: AutoSubmission @MockK lateinit var analyticsKeySubmissionCollector: AnalyticsKeySubmissionCollector - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: SubmissionSymptomIntroductionViewModel @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTanFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTanFragmentTest.kt index 4e5d114ea..d96287b09 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTanFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTanFragmentTest.kt @@ -16,17 +16,14 @@ import io.mockk.MockKAnnotations import io.mockk.impl.annotations.MockK import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionTanFragmentTest : BaseUITest() { @@ -38,13 +35,6 @@ class SubmissionTanFragmentTest : BaseUITest() { submissionRepository = submissionRepository ) - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultAvailableFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultAvailableFragmentTest.kt index b8c94ec58..d60699c94 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultAvailableFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultAvailableFragmentTest.kt @@ -23,15 +23,12 @@ import io.mockk.spyk import kotlinx.coroutines.flow.flowOf import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionTestResultAvailableFragmentTest : BaseUITest() { @@ -47,13 +44,6 @@ class SubmissionTestResultAvailableFragmentTest : BaseUITest() { private val resultAvailableFragmentArgs = SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle() - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultConsentGivenFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultConsentGivenFragmentTest.kt index 0a4616394..0a10193fc 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultConsentGivenFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultConsentGivenFragmentTest.kt @@ -30,17 +30,14 @@ import io.mockk.spyk import org.joda.time.Instant import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionTestResultConsentGivenFragmentTest : BaseUITest() { @@ -53,13 +50,6 @@ class SubmissionTestResultConsentGivenFragmentTest : BaseUITest() { private val consentGivenFragmentArgs = SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle() - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: SubmissionTestResultConsentGivenViewModel private val navController = TestNavHostController( diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultFragmentTest.kt index e999cd175..0af3284c7 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultFragmentTest.kt @@ -24,17 +24,14 @@ import kotlinx.coroutines.flow.flowOf import org.joda.time.Instant import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionTestResultFragmentTest : BaseUITest() { @@ -44,13 +41,6 @@ class SubmissionTestResultFragmentTest : BaseUITest() { private val pendingFragmentArgs = SubmissionTestResultPendingFragmentArgs(testType = CoronaTest.Type.PCR).toBundle() - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNegativeFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNegativeFragmentTest.kt index 5439d1759..34256e3a3 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNegativeFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNegativeFragmentTest.kt @@ -21,15 +21,12 @@ import kotlinx.coroutines.flow.flowOf import org.joda.time.Instant import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionTestResultNegativeFragmentTest : BaseUITest() { @@ -41,13 +38,6 @@ class SubmissionTestResultNegativeFragmentTest : BaseUITest() { private val resultNegativeFragmentArgs = SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle() - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNoConsentGivenFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNoConsentGivenFragmentTest.kt index a1c88a8f2..94f0bc3c0 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNoConsentGivenFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionTestResultNoConsentGivenFragmentTest.kt @@ -21,15 +21,12 @@ import io.mockk.spyk import org.joda.time.Instant import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionTestResultNoConsentGivenFragmentTest : BaseUITest() { @@ -41,13 +38,6 @@ class SubmissionTestResultNoConsentGivenFragmentTest : BaseUITest() { private val noConsentGivenFragmentArgs = SubmissionTestResultConsentGivenFragmentArgs(testType = CoronaTest.Type.PCR).toBundle() - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: SubmissionTestResultNoConsentViewModel @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionYourConsentFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionYourConsentFragmentTest.kt index cd8716687..e801a642c 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionYourConsentFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionYourConsentFragmentTest.kt @@ -15,15 +15,12 @@ import io.mockk.impl.annotations.MockK import kotlinx.coroutines.flow.flowOf import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.captureScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class SubmissionYourConsentFragmentTest : BaseUITest() { @@ -32,13 +29,6 @@ class SubmissionYourConsentFragmentTest : BaseUITest() { @MockK lateinit var interoperabilityRepository: InteroperabilityRepository @MockK lateinit var testType: CoronaTest.Type - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private lateinit var viewModel: SubmissionYourConsentViewModel @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt index 262b6e425..7caba09a4 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/tracing/TracingDetailsFragmentTest.kt @@ -21,17 +21,14 @@ import io.mockk.impl.annotations.MockK import io.mockk.spyk import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.TestDispatcherProvider import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class TracingDetailsFragmentTest : BaseUITest() { @@ -46,13 +43,6 @@ class TracingDetailsFragmentTest : BaseUITest() { private lateinit var viewModel: TracingDetailsFragmentViewModel - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - @Before fun setup() { MockKAnnotations.init(this, relaxed = true) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/vaccination/VaccinationConsentFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/vaccination/VaccinationConsentFragmentTest.kt index 10e7acdf1..d3538b7ba 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/vaccination/VaccinationConsentFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/vaccination/VaccinationConsentFragmentTest.kt @@ -9,25 +9,16 @@ import io.mockk.MockKAnnotations import io.mockk.impl.annotations.MockK import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class VaccinationConsentFragmentTest : BaseUITest() { - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() @MockK lateinit var viewModel: VaccinationConsentViewModel diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/details/VaccinationDetailsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/details/VaccinationDetailsFragmentTest.kt index a63d7dbb9..25da8d359 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/details/VaccinationDetailsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/details/VaccinationDetailsFragmentTest.kt @@ -23,29 +23,19 @@ import org.joda.time.LocalDate import org.joda.time.format.DateTimeFormat import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) class VaccinationDetailsFragmentTest : BaseUITest() { @MockK lateinit var vaccinationDetailsViewModel: VaccinationDetailsViewModel - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private val args = VaccinationDetailsFragmentArgs("vaccinationCertificateId").toBundle() @Before diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/list/VaccinationListFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/list/VaccinationListFragmentTest.kt index ea39fc1ea..a017ec7b7 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/list/VaccinationListFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/vaccination/ui/list/VaccinationListFragmentTest.kt @@ -30,29 +30,19 @@ import org.joda.time.LocalDate import org.joda.time.format.DateTimeFormat import org.junit.After import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import testhelpers.BaseUITest import testhelpers.Screenshot -import testhelpers.SystemUIDemoModeRule import testhelpers.launchFragment2 import testhelpers.launchFragmentInContainer2 import testhelpers.takeScreenshot -import tools.fastlane.screengrab.locale.LocaleTestRule @RunWith(AndroidJUnit4::class) internal class VaccinationListFragmentTest : BaseUITest() { @MockK lateinit var vaccinationListViewModel: VaccinationListViewModel - @Rule - @JvmField - val localeTestRule = LocaleTestRule() - - @get:Rule - val systemUIDemoModeRule = SystemUIDemoModeRule() - private val applicationContext = ApplicationProvider.getApplicationContext<Context>() private val testQrCode = BitmapFactory.decodeResource(applicationContext.resources, R.drawable.test_qr_code) private val formatter = DateTimeFormat.forPattern("dd.MM.yyyy") diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/BaseUITest.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/BaseUITest.kt index 65f9ce8d3..5adbbfc14 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/BaseUITest.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/BaseUITest.kt @@ -15,6 +15,9 @@ abstract class BaseUITest : BaseTestInstrumentation() { Manifest.permission.WRITE_EXTERNAL_STORAGE ) + @get:Rule + val systemUIDemoModeRule = SystemUIDemoModeRule() + inline fun <reified T : CWAViewModel> setupMockViewModel(factory: CWAViewModelFactory<T>) { MockViewModelModule.CREATORS[T::class.java] = factory } diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/ScreenShotter.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/ScreenShotter.kt index c5002121e..3898fdd65 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/ScreenShotter.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/ScreenShotter.kt @@ -8,11 +8,8 @@ import androidx.annotation.StyleRes import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentFactory import androidx.test.espresso.ViewAction +import androidx.test.platform.app.InstrumentationRegistry import de.rki.coronawarnapp.R -import tools.fastlane.screengrab.Screengrab -import tools.fastlane.screengrab.ScreenshotCallback -import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy -import tools.fastlane.screengrab.file.Chmod import java.io.BufferedOutputStream import java.io.File import java.io.FileOutputStream @@ -26,11 +23,8 @@ inline fun <reified T> takeScreenshot(suffix: String = "", delay: Long = SCREENS Thread.sleep(delay) val simpleName = T::class.simpleName val name = if (suffix.isEmpty()) simpleName else simpleName.plus("_$suffix") - Screengrab.screenshot( - name, - UiAutomatorScreenshotStrategy(), - SDCardCallback - ) + val screenshot = InstrumentationRegistry.getInstrumentation().uiAutomation.takeScreenshot() + SDCard.screenshotCaptured(name ?: System.currentTimeMillis().toString(), screenshot) } /** @@ -52,13 +46,13 @@ inline fun <reified F : Fragment> captureScreenshot( /** * Saves screenshots on the device's sdcard */ -object SDCardCallback : ScreenshotCallback { +object SDCard { private const val ROOT_DIRECTORY = "/sdcard" private const val SCREENSHOTS_DIRECTORY = "screenshots" private const val SCREENSHOT_FORMAT = ".png" private const val IMAGE_QUALITY = 100 - override fun screenshotCaptured(screenshotName: String, screenshot: Bitmap) { + fun screenshotCaptured(screenshotName: String, screenshot: Bitmap) { try { val directory = File(ROOT_DIRECTORY, SCREENSHOTS_DIRECTORY) if (!directory.exists()) { @@ -71,10 +65,9 @@ object SDCardCallback : ScreenshotCallback { BufferedOutputStream(FileOutputStream(screenshotFile)).use { screenshot.compress(Bitmap.CompressFormat.PNG, IMAGE_QUALITY, it) - Chmod.chmodPlusR(screenshotFile) screenshot.recycle() } - Log.d("Screengrab", "Captured screenshot \"${screenshotFile.name}\"") + Log.d("SDCard", "Captured screenshot \"${screenshotFile.name}\"") } catch (e: Exception) { throw RuntimeException("Unable to capture screenshot.", e) } diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/keydownload/ui/KeyFileDownloadAdapter.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/keydownload/ui/KeyFileDownloadAdapter.kt index 231496e76..97bfffb44 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/keydownload/ui/KeyFileDownloadAdapter.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/keydownload/ui/KeyFileDownloadAdapter.kt @@ -40,9 +40,9 @@ class KeyFileDownloadAdapter( class CachedKeyViewHolder( val parent: ViewGroup ) : BaseAdapter.VH( - R.layout.fragment_test_keydownload_adapter_line, - parent - ), + R.layout.fragment_test_keydownload_adapter_line, + parent + ), BindableVH<CachedKeyListItem, FragmentTestKeydownloadAdapterLineBinding> { override val viewBinding = lazy { FragmentTestKeydownloadAdapterLineBinding.bind(itemView) } diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/submission/ui/TEKHistoryAdapter.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/submission/ui/TEKHistoryAdapter.kt index 88f6c7d67..332a2fbf5 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/submission/ui/TEKHistoryAdapter.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/submission/ui/TEKHistoryAdapter.kt @@ -31,9 +31,9 @@ class TEKHistoryAdapter : BaseAdapter<TEKHistoryAdapter.VH>(), AsyncDiffUtilAdap class VH( val parent: ViewGroup ) : BaseAdapter.VH( - R.layout.fragment_test_submission_tekhistory_line, - parent - ), + R.layout.fragment_test_submission_tekhistory_line, + parent + ), BindableVH<TEKHistoryItem, FragmentTestSubmissionTekhistoryLineBinding> { override val viewBinding = lazy { FragmentTestSubmissionTekhistoryLineBinding.bind(itemView) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureWindowRiskCalculationConfigMapper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureWindowRiskCalculationConfigMapper.kt index dc447aff6..21c81facd 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureWindowRiskCalculationConfigMapper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureWindowRiskCalculationConfigMapper.kt @@ -42,9 +42,9 @@ class ExposureWindowRiskCalculationConfigMapper @Inject constructor() : transmissionRiskLevelEncoding = riskCalculationParameters.trlEncoding, transmissionRiskLevelFilters = riskCalculationParameters.trlFiltersList, normalizedTimePerExposureWindowToRiskLevelMapping = - riskCalculationParameters.normalizedTimePerEWToRiskLevelMappingList, + riskCalculationParameters.normalizedTimePerEWToRiskLevelMappingList, normalizedTimePerDayToRiskLevelMappingList = - riskCalculationParameters.normalizedTimePerDayToRiskLevelMappingList, + riskCalculationParameters.normalizedTimePerDayToRiskLevelMappingList, transmissionRiskValueMapping = riskCalculationParameters.transmissionRiskValueMappingList, diagnosisKeysDataMapping = rawConfig.diagnosisKeysDataMapping() ) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/http/CwaWebException.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/http/CwaWebException.kt index 2f69c1026..eb5a3bc33 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/http/CwaWebException.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/http/CwaWebException.kt @@ -22,10 +22,10 @@ open class CwaServerError( message: String?, cause: Throwable? = null ) : CwaWebException( - statusCode = statusCode, - message = message, - cause = cause -), + statusCode = statusCode, + message = message, + cause = cause + ), HasHumanReadableError { init { if (statusCode !in 500..599) { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportedException.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportedException.kt index b7e86078c..6792d0a3c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportedException.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/exception/reporting/ReportedException.kt @@ -8,9 +8,9 @@ open class ReportedException( cause: Throwable? = null, override val resId: Int? = null ) : Exception( - message, - cause -), + message, + cause + ), ReportedExceptionInterface open class ReportedIOException( @@ -19,9 +19,9 @@ open class ReportedIOException( cause: Throwable? = null, override val resId: Int? = null ) : IOException( - message, - cause -), + message, + cause + ), ReportedExceptionInterface interface ReportedExceptionInterface { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt index 931ccdbda..295ba520c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt @@ -9,8 +9,8 @@ import java.io.IOException class InsufficientStorageException( val result: DeviceStorage.CheckResult ) : IOException( - "Not enough free space: ${result.requiredBytes}B are required and only ${result.freeBytes}B are available." -), + "Not enough free space: ${result.requiredBytes}B are required and only ${result.freeBytes}B are available." + ), HasHumanReadableError { override fun toHumanReadableError(context: Context): HumanReadableError { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSourceTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSourceTest.kt index cf21c6b07..bc306b379 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSourceTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSourceTest.kt @@ -82,7 +82,8 @@ class DefaultAppConfigSourceTest : BaseIOTest() { @Test fun `exceptions when getting the default config are rethrown`() = runBlockingTest { - every { assetManager.open("default_app_config_android.bin") } throws FileNotFoundException("default_app_config_android.bin does not exist") + every { assetManager.open("default_app_config_android.bin") } throws + FileNotFoundException("default_app_config_android.bin does not exist") val instance = createInstance() shouldThrowAny { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/CoronaTestCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/CoronaTestCensorTest.kt index 4522f2a9d..7414771a0 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/CoronaTestCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/CoronaTestCensorTest.kt @@ -18,6 +18,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest +@Suppress("MaxLineLength") class CoronaTestCensorTest : BaseTest() { @MockK lateinit var coronaTestRepository: CoronaTestRepository diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/DiaryLocationCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/DiaryLocationCensorTest.kt index 17610b27d..9ed1e19a3 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/DiaryLocationCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/DiaryLocationCensorTest.kt @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test import testhelpers.BaseTest import kotlin.concurrent.thread +@Suppress("MaxLineLength") class DiaryLocationCensorTest : BaseTest() { @MockK lateinit var diaryRepo: ContactDiaryRepository diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RACoronaTestCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RACoronaTestCensorTest.kt index 960614377..9cb76199d 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RACoronaTestCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RACoronaTestCensorTest.kt @@ -17,6 +17,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest +@Suppress("MaxLineLength") internal class RACoronaTestCensorTest : BaseTest() { @MockK lateinit var coronaTestRepository: CoronaTestRepository diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RatQrCodeCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RatQrCodeCensorTest.kt index 443db598f..1e524a83a 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RatQrCodeCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/RatQrCodeCensorTest.kt @@ -9,6 +9,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +@Suppress("MaxLineLength") internal class RatQrCodeCensorTest { private val testHash = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/TraceLocationCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/TraceLocationCensorTest.kt index f3d274d7c..0f64442f8 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/TraceLocationCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/TraceLocationCensorTest.kt @@ -19,6 +19,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest +@Suppress("MaxLineLength") internal class TraceLocationCensorTest : BaseTest() { @MockK lateinit var traceLocationRepo: TraceLocationRepository diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/submission/RatProfileCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/submission/RatProfileCensorTest.kt index e516437fe..cab39ec36 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/submission/RatProfileCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/submission/RatProfileCensorTest.kt @@ -14,6 +14,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest +@Suppress("MaxLineLength") internal class RatProfileCensorTest : BaseTest() { @MockK lateinit var ratProfileSettings: RATProfileSettings diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/vaccination/CertificateQrCodeCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/vaccination/CertificateQrCodeCensorTest.kt index 5d2f3d05c..d76f485ed 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/vaccination/CertificateQrCodeCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/vaccination/CertificateQrCodeCensorTest.kt @@ -10,6 +10,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +@Suppress("MaxLineLength") internal class CertificateQrCodeCensorTest { private val testRawString = diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/debuglog/internal/DebugLogStorageCheckTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/debuglog/internal/DebugLogStorageCheckTest.kt index d8d72156f..8be40df0b 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/debuglog/internal/DebugLogStorageCheckTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/debuglog/internal/DebugLogStorageCheckTest.kt @@ -14,7 +14,6 @@ import io.mockk.mockk import io.mockk.slot import io.mockk.verify import kotlinx.coroutines.test.runBlockingTest -import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -37,10 +36,6 @@ class DebugLogStorageCheckTest : BaseTest() { coEvery { logWriter.write(any()) } just Runs } - @AfterEach - fun teardown() { - } - private fun createInstance() = DebugLogStorageCheck( targetPath = targetPath, timeProvider = { ourTime }, diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/ContactDiarySettingsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/ContactDiarySettingsTest.kt index f2827a44b..df46c8f17 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/ContactDiarySettingsTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/ContactDiarySettingsTest.kt @@ -42,8 +42,9 @@ class ContactDiarySettingsTest { } @Test - fun `onboarded`() { + fun onboarded() { every { intPreference.value } returns 1 - ContactDiarySettings(preferences).onboardingStatus shouldBe ContactDiarySettings.OnboardingStatus.RISK_STATUS_1_12 + ContactDiarySettings(preferences).onboardingStatus shouldBe + ContactDiarySettings.OnboardingStatus.RISK_STATUS_1_12 } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditLocationsViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditLocationsViewModelTest.kt index e3c6768ae..abf4044de 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditLocationsViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditLocationsViewModelTest.kt @@ -52,7 +52,8 @@ class ContactDiaryEditLocationsViewModelTest { viewModel = createInstance() viewModel.navigationEvent.observeForever { } viewModel.onDeleteAllLocationsClick() - viewModel.navigationEvent.value shouldBe ContactDiaryEditLocationsViewModel.NavigationEvent.ShowDeletionConfirmationDialog + viewModel.navigationEvent.value shouldBe + ContactDiaryEditLocationsViewModel.NavigationEvent.ShowDeletionConfirmationDialog } @Test @@ -75,7 +76,9 @@ class ContactDiaryEditLocationsViewModelTest { viewModel.navigationEvent.observeForever { } viewModel.onEditLocationClick(location) viewModel.navigationEvent.value shouldBe - ContactDiaryEditLocationsViewModel.NavigationEvent.ShowLocationDetailFragment(location.toContactDiaryLocationEntity()) + ContactDiaryEditLocationsViewModel.NavigationEvent.ShowLocationDetailFragment( + location.toContactDiaryLocationEntity() + ) } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditPersonsViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditPersonsViewModelTest.kt index babe9784b..8acd015c5 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditPersonsViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/edit/ContactDiaryEditPersonsViewModelTest.kt @@ -51,7 +51,8 @@ class ContactDiaryEditPersonsViewModelTest { viewModel = createInstance() viewModel.navigationEvent.observeForever { } viewModel.onDeleteAllPersonsClick() - viewModel.navigationEvent.value shouldBe ContactDiaryEditPersonsViewModel.NavigationEvent.ShowDeletionConfirmationDialog + viewModel.navigationEvent.value shouldBe + ContactDiaryEditPersonsViewModel.NavigationEvent.ShowDeletionConfirmationDialog } @Test @@ -74,7 +75,9 @@ class ContactDiaryEditPersonsViewModelTest { viewModel.navigationEvent.observeForever { } viewModel.onEditPersonClick(person) viewModel.navigationEvent.value shouldBe - ContactDiaryEditPersonsViewModel.NavigationEvent.ShowPersonDetailFragment(person.toContactDiaryPersonEntity()) + ContactDiaryEditPersonsViewModel.NavigationEvent.ShowPersonDetailFragment( + person.toContactDiaryPersonEntity() + ) } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporterTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporterTest.kt index 3e31ce1cb..14b11d57c 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporterTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/exporter/ContactDiaryExporterTest.kt @@ -25,6 +25,7 @@ import testhelpers.extensions.CoroutinesTestExtension @TestInstance(TestInstance.Lifecycle.PER_CLASS) @ExtendWith(MockKExtension::class, CoroutinesTestExtension::class) +@Suppress("MaxLineLength") internal class ContactDiaryExporterTest { @MockK lateinit var timeStamper: TimeStamper @@ -74,17 +75,17 @@ internal class ContactDiaryExporterTest { personEncounters = emptyList(), locationVisits = emptyList(), expectedExport = - """ + """ Kontakte der letzten 15 Tage (01.01.2021 - 15.01.2021) Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG. - """.trimIndent() + """.trimIndent() ), ExporterTestItem( personEncounters = ContactDiaryData.TWO_PERSONS_NO_ADDITIONAL_DATA, locationVisits = ContactDiaryData.TWO_LOCATIONS_NO_ADDITIONAL_DATA, expectedExport = - """ + """ Kontakte der letzten 15 Tage (01.01.2021 - 15.01.2021) Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG. @@ -93,13 +94,13 @@ internal class ContactDiaryExporterTest { 01.01.2021 Andrea Steinhauer 01.01.2021 Bakery - """.trimIndent() + """.trimIndent() ), ExporterTestItem( personEncounters = ContactDiaryData.TWO_PERSONS_WITH_PHONE_NUMBERS, locationVisits = ContactDiaryData.TWO_LOCATIONS_WITH_EMAIL, expectedExport = - """ + """ Kontakte der letzten 15 Tage (01.01.2021 - 15.01.2021) Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG. @@ -108,13 +109,13 @@ internal class ContactDiaryExporterTest { 01.01.2021 Andrea Steinhauer; Tel. +49 123 456789 01.01.2021 Bakery; eMail baker@ibakeyourbread.com - """.trimIndent() + """.trimIndent() ), ExporterTestItem( personEncounters = ContactDiaryData.TWO_PERSONS_WITH_PHONE_NUMBERS_AND_EMAIL, locationVisits = ContactDiaryData.TWO_LOCATIONS_WITH_PHONE_NUMBERS_AND_EMAIL, expectedExport = - """ + """ Kontakte der letzten 15 Tage (01.01.2021 - 15.01.2021) Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG. @@ -123,13 +124,13 @@ internal class ContactDiaryExporterTest { 01.01.2021 Andrea Steinhauer; Tel. +49 123 456789; eMail andrea.steinhauer@example.com 01.01.2021 Bakery; Tel. +11 222 333333; eMail baker@ibakeyourbread.com - """.trimIndent() + """.trimIndent() ), ExporterTestItem( personEncounters = ContactDiaryData.TWO_PERSONS_WITH_ATTRIBUTES, locationVisits = ContactDiaryData.TWO_LOCATIONS_WITH_DURATION, expectedExport = - """ + """ Kontakte der letzten 15 Tage (01.01.2021 - 15.01.2021) Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG. @@ -138,13 +139,13 @@ internal class ContactDiaryExporterTest { 01.01.2021 Andrea Steinhauer; Kontaktdauer < 15 Minuten; mit Maske; im Freien 01.01.2021 Bakery; Dauer 00:15 h - """.trimIndent() + """.trimIndent() ), ExporterTestItem( personEncounters = ContactDiaryData.TWO_PERSONS_WITH_CIRCUMSTANCES, locationVisits = ContactDiaryData.TWO_LOCATIONS_WITH_CIRCUMSTANCES, expectedExport = - """ + """ Kontakte der letzten 15 Tage (01.01.2021 - 15.01.2021) Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG. @@ -153,7 +154,7 @@ internal class ContactDiaryExporterTest { 01.01.2021 Andrea Steinhauer; Sicherheitsmaßnahmen eingehalten 01.01.2021 Bakery; Very crowdy, but delicious bread - """.trimIndent() + """.trimIndent() ) ).map { testItem -> Arguments.of(testItem) } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModelTest.kt index 1644a3c19..b8525e0b8 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModelTest.kt @@ -214,11 +214,13 @@ open class ContactDiaryOverviewViewModelTest { with(createInstance()) { onItemPress(listItem) val navigationEvent = routeToScreen.getOrAwaitValue() - navigationEvent should beInstanceOf(ContactDiaryOverviewNavigationEvents.NavigateToContactDiaryDayFragment::class) + navigationEvent should + beInstanceOf(ContactDiaryOverviewNavigationEvents.NavigateToContactDiaryDayFragment::class) navigationEvent as ContactDiaryOverviewNavigationEvents.NavigateToContactDiaryDayFragment - navigationEvent.localDateString shouldBe ContactDiaryOverviewNavigationEvents.NavigateToContactDiaryDayFragment( - listItem.date - ).localDateString + navigationEvent.localDateString shouldBe + ContactDiaryOverviewNavigationEvents.NavigateToContactDiaryDayFragment( + listItem.date + ).localDateString } } @@ -508,8 +510,10 @@ open class ContactDiaryOverviewViewModelTest { // In this test, now = January, 15 every { timeStamper.nowUTC } returns Instant.parse("2021-01-15T00:00:00.000Z") - every { contactDiaryRepository.personEncounters } returns flowOf(ContactDiaryData.TWO_PERSONS_WITH_PHONE_NUMBERS_AND_EMAIL) - every { contactDiaryRepository.locationVisits } answers { flowOf(ContactDiaryData.TWO_LOCATIONS_WITH_DURATION) } + every { contactDiaryRepository.personEncounters } returns + flowOf(ContactDiaryData.TWO_PERSONS_WITH_PHONE_NUMBERS_AND_EMAIL) + every { contactDiaryRepository.locationVisits } answers + { flowOf(ContactDiaryData.TWO_LOCATIONS_WITH_DURATION) } val vm = createInstance() diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/util/ContactDiaryExportStringsMock.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/util/ContactDiaryExportStringsMock.kt index 2690e74e2..64b3ce404 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/util/ContactDiaryExportStringsMock.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/contactdiary/util/ContactDiaryExportStringsMock.kt @@ -20,13 +20,17 @@ fun mockStringsForContactDiaryExporterTests(context: Context) { every { context.getString(R.string.contact_diary_export_intro_two) - } answers { "Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG." } + } answers { + "Die nachfolgende Liste dient dem zuständigen Gesundheitsamt zur Kontaktnachverfolgung gem. § 25 IfSG." + } every { context.getString(R.string.contact_diary_export_prefix_phone) } returns "Tel." every { context.getString(R.string.contact_diary_export_prefix_email) } returns "eMail" - every { context.getString(R.string.contact_diary_export_durations_less_than_15min) } returns "Kontaktdauer < 15 Minuten" - every { context.getString(R.string.contact_diary_export_durations_longer_than_15min) } returns "Kontaktdauer > 15 Minuten" + every { context.getString(R.string.contact_diary_export_durations_less_than_15min) } returns + "Kontaktdauer < 15 Minuten" + every { context.getString(R.string.contact_diary_export_durations_longer_than_15min) } returns + "Kontaktdauer > 15 Minuten" every { context.getString(R.string.contact_diary_export_wearing_mask) } returns "mit Maske" every { context.getString(R.string.contact_diary_export_wearing_no_mask) } returns "ohne Maske" diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/qrcode/TestQrCodes.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/qrcode/TestQrCodes.kt index b29edd24d..2756a5bd0 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/qrcode/TestQrCodes.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/qrcode/TestQrCodes.kt @@ -1,24 +1,39 @@ package de.rki.coronawarnapp.coronatest.qrcode -internal val pcrQrCode1 = "HTTPS://LOCALHOST/?123456-12345678-1234-4DA7-B166-B86D85475064" -internal val pcrQrCode2 = "https://localhost/?123456-12345678-1234-4DA7-B166-B86D85475064" -internal val pcrQrCode3 = "https://LOCALHOST/?123456-12345678-1234-4DA7-B166-B86D85475064" +internal const val pcrQrCode1 = "HTTPS://LOCALHOST/?123456-12345678-1234-4DA7-B166-B86D85475064" +internal const val pcrQrCode2 = "https://localhost/?123456-12345678-1234-4DA7-B166-B86D85475064" +internal const val pcrQrCode3 = "https://LOCALHOST/?123456-12345678-1234-4DA7-B166-B86D85475064" -internal val raQrCode1 = +@Suppress("MaxLineLength") +internal const val raQrCode1 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTgzMTEsInNhbHQiOiJBODczOTVDRjYyMjc1QzRCQjczMjAxOERFRTRDQzhCRSIsInRlc3RpZCI6IjQwNDBkNTRlLWIzNmYtNGQ1Yi05MThiLTExODZjM2E0OTZhNSIsImhhc2giOiI4MzFhNzNmNGZhODZkMDdjMjViOTdjNzdiZjg5MzNhN2Q5MzAzODIxZDRjNzdiZDc5YzlkNzJlMmU0ZTI1MWYyIiwiZm4iOiJEeWxhbiIsImxuIjoiR2FyZGluZXIiLCJkb2IiOiIxOTY3LTEyLTIyIn0=" -internal val raQrCode2 = + +@Suppress("MaxLineLength") +internal const val raQrCode2 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTgzMzMsInNhbHQiOiI5Nzk5OUY4QTBFMjBBMDgxMDMyMDdGQzkxOEQzRTVFRiIsInRlc3RpZCI6IjE3ZjFlOGMxLTBiMWMtNDE1Ni1iMTZkLTlmMmQwNzEzMDJmNSIsImhhc2giOiIzMDcxNmQzM2FkNDFhZjQwNTk1Y2IyOThkMDcwMDllM2QwZjIxZDk5Njg4ZWZkOTIyNGQ4OWQ0OTQ3YjRkZDU3IiwiZm4iOiJIYXJyaWV0IiwibG4iOiJCbGFuYyIsImRvYiI6IjE5OTUtMDItMTUifQ==" -internal val raQrCode3 = + +@Suppress("MaxLineLength") +internal const val raQrCode3 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTgzNTIsInNhbHQiOiJDRjBDNTQ3RkY2RDMwOTlBMkIwNkMxQzRFNEYwOEFGOSIsInRlc3RpZCI6ImY0N2VmODA0LTZmMGMtNDhiMy1hODY5LWUyZjg4NmIxMjU0ZiIsImhhc2giOiI3ZGNlMDhkYjBkNGFiZDVhYzFkMjQ5OGI1NzFhZmIyMjFjYTk0N2M3NWM4NDdkMDU0NjZiNGNmZTlkOTVkYzY2IiwiZm4iOiJKYWNvYiIsImxuIjoiVHlsZXIiLCJkb2IiOiIxOTYzLTAzLTE3In0=" -internal val raQrCode4 = + +@Suppress("MaxLineLength") +internal const val raQrCode4 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTgzNjksInNhbHQiOiJEQTg3M0YwOUJCQzZCQzVFMEQ0QTdBMzc2MjZERkMwNSIsInRlc3RpZCI6IjlmYjYzNWE2LThhZTQtNDVjZS1iZTZkLTg5MjdmMjM1ZmIzNiIsImhhc2giOiJmNGYzMDU0NTMwODI1MjkxYjhmMDQ3MWZkZTRiY2EzNTljOGVjZDI0ZTBmNTkxNTA5NTQyY2ZmNGJhNDBkNmY1IiwiZm4iOiJFZGRpZSIsImxuIjoiQm91Y2hlciIsImRvYiI6IjE5NzktMDEtMjMifQ==" -internal val raQrCode5 = + +@Suppress("MaxLineLength") +internal const val raQrCode5 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTgzODIsInNhbHQiOiI2RUJCMUM4NTc0QUYxQzcwQkY2MTNGQjMzNDM3MkM3MiIsInRlc3RpZCI6Ijg2MzkzMTE1LWVkYjAtNGE3Zi1iZTg1LWEwYjViMjY5M2Q3MSIsImhhc2giOiIzMmQxYjk4MTRjNWU0ZjI3Mjc5NWU0NjNhMmViZjI5Y2Y1ZDZkYzdiZmRhODNhYzViZWY5Y2Q5M2E3YjMxMjYwIiwiZm4iOiJBZGVsYWlkZSIsImxuIjoiSHVpc21hbiIsImRvYiI6IjE5NTktMDgtMDIifQ==" -internal val raQrCode6 = + +@Suppress("MaxLineLength") +internal const val raQrCode6 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTgzOTcsInNhbHQiOiI3MDcyQzAyMTkyM0ZFOEMzMDVDNTAxQkU5MjQyMjNBQyIsInRlc3RpZCI6IjhmMzA0OTE4LWI2YmMtNDQyOS1iYzhlLWMzMzRkMjdhNTdiNCIsImhhc2giOiI2ZjVhMjJhYzY2ZTc1Y2JiYTE3MTBlN2IxZWMwZTllMDk4NjUyMjY0MWE3NTYyNGY0MGZhMDc4YTZkZjY0ZTVjIiwiZm4iOiJBbmRyZSIsImxuIjoiQmFyZ2VsbGluaSIsImRvYiI6IjE5OTItMTEtMDcifQ==" -internal val raQrCode7 = + +@Suppress("MaxLineLength") +internal const val raQrCode7 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MTg0MjMsInNhbHQiOiJEM0Y1MzcyODU2NkMxMDFENjE1MkVCQ0I0OEMxMkFCOCIsInRlc3RpZCI6Ijc5NWIxY2MwLWU2NjQtNGFmZi05NTk3LWU3MTk2ODE4ZGVmYiIsImhhc2giOiI3NmMxMjJiOTlmZWVmZmM5Mjc3MTE2YjUwZGIwZGM1NjI0ZjY5OWFiMzliMDAwOWMwYzg5YmRlMWNjZjM4YmQxIiwiZm4iOiJWaWN0b3JpYSIsImxuIjoiTWFubmVsbGkiLCJkb2IiOiIxOTc4LTA0LTIxIn0=" -internal val raQrCode8 = + +@Suppress("MaxLineLength") +internal const val raQrCode8 = "https://s.coronawarn.app?v=1#eyJ0aW1lc3RhbXAiOjE2MTk2MjEzMzEsInNhbHQiOiI5NERDMkUyRkNCNTE2NDFFQzA5RkZENjVEMkJEMDg4QiIsInRlc3RpZCI6ImMyMGI5OTgxLWZmNzAtNGRmOC1hYTAyLTUwOTdmMmJkN2YzYyIsImhhc2giOiI1MmVlZjA3YjQwYzU1ODM0OTg3MGQ3YTA2Yzc0OGIwOTAxNGMxMTBlYTkzYjZhNmRhNDhkOWI4NTU0NTU2MzY0In0=" // { @@ -30,7 +45,8 @@ internal val raQrCode8 = // "salt":"510f3d750c2fc631fbcfe32cb06bbba9", // "hash":"d6e4d0181d8109bf05b346a0d2e0ef0cc472eed70d9df8c4b9ae5c7a009f3e34" // } -internal val raQrCodeEmptyStrings = +@Suppress("MaxLineLength") +internal const val raQrCodeEmptyStrings = "https://s.coronawarn.app?v=1#ewogICAgImZuIjoiIiwKICAgICJsbiI6IiIsCiAgICAiZG9iIjoiIiwKICAgICJ0ZXN0aWQiOiIwZTYwMGI0Mi1jYzIxLTRlNzUtOTE0Yy03MDYwMzE0M2I2Y2IiLAogICAgInRpbWVzdGFtcCI6IDE2MTkwMTI5NTIsCiAgICAic2FsdCI6IjUxMGYzZDc1MGMyZmM2MzFmYmNmZTMyY2IwNmJiYmE5IiwKICAgICJoYXNoIjoiZDZlNGQwMTgxZDgxMDliZjA1YjM0NmEwZDJlMGVmMGNjNDcyZWVkNzBkOWRmOGM0YjlhZTVjN2EwMDlmM2UzNCIKfQ" // { @@ -42,5 +58,6 @@ internal val raQrCodeEmptyStrings = // "salt":"510f3d750c2fc631fbcfe32cb06bbba9", // "hash":"d6e4d0181d8109bf05b346a0d2e0ef0cc472eed70d9df8c4b9ae5c7a009f3e34" // } -internal val raQrIncompletePersonalData = +@Suppress("MaxLineLength") +internal const val raQrIncompletePersonalData = "https://s.coronawarn.app?v=1#ewogICAgImZuIjoiTWF4IiwKICAgICJsbiI6IiIsCiAgICAiZG9iIjoiIiwKICAgICJ0ZXN0aWQiOiIwZTYwMGI0Mi1jYzIxLTRlNzUtOTE0Yy03MDYwMzE0M2I2Y2IiLAogICAgInRpbWVzdGFtcCI6IDE2MTkwMTI5NTIsCiAgICAic2FsdCI6IjUxMGYzZDc1MGMyZmM2MzFmYmNmZTMyY2IwNmJiYmE5IiwKICAgICJoYXNoIjoiZDZlNGQwMTgxZDgxMDliZjA1YjM0NmEwZDJlMGVmMGNjNDcyZWVkNzBkOWRmOGM0YjlhZTVjN2EwMDlmM2UzNCIKfQ" diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/exposurewindows/AnalyticsExposureWindowDonorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/exposurewindows/AnalyticsExposureWindowDonorTest.kt index 1014934ee..ad5057215 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/exposurewindows/AnalyticsExposureWindowDonorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/exposurewindows/AnalyticsExposureWindowDonorTest.kt @@ -103,7 +103,9 @@ class AnalyticsExposureWindowDonorTest : BaseTest() { coEvery { analyticsExposureWindowRepository.getAllNew() } returns wrappers coEvery { analyticsExposureWindowRepository.moveToReported(wrappers) } returns reported runBlockingTest { - (donor.beginDonation(request) as AnalyticsExposureWindowDonor.Contribution).data shouldBe wrappers.asPpaData() + ( + donor.beginDonation(request) as AnalyticsExposureWindowDonor.Contribution + ).data shouldBe wrappers.asPpaData() } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultTest.kt index ed70c6224..cb7200c36 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/analytics/modules/testresult/AnalyticsPCRTestResultTest.kt @@ -88,9 +88,11 @@ class AnalyticsPCRTestResultTest : BaseTest() { fun `No donation when test result is PENDING and hours isn't greater or equal to config hours`() { runBlockingTest { every { testResultSettings.testScannedAfterConsent } returns mockFlowPreference(true) - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) + every { testResultSettings.testResultAtRegistration } returns + mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) - testResultDonor.beginDonation(TestRequest) shouldBe AnalyticsTestResultDonor.TestResultMetadataNoContribution + testResultDonor.beginDonation(TestRequest) shouldBe + AnalyticsTestResultDonor.TestResultMetadataNoContribution } } @@ -98,7 +100,8 @@ class AnalyticsPCRTestResultTest : BaseTest() { fun `Donation is collected when test result is PENDING and hours is greater or equal to config hours`() { runBlockingTest { every { testResultSettings.testScannedAfterConsent } returns mockFlowPreference(true) - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) + every { testResultSettings.testResultAtRegistration } returns + mockFlowPreference(CoronaTestResult.PCR_OR_RAT_PENDING) val timeDayBefore = baseTime.minus(Duration.standardDays(1)) every { testResultSettings.testRegisteredAt } returns mockFlowPreference(timeDayBefore) @@ -118,7 +121,8 @@ class AnalyticsPCRTestResultTest : BaseTest() { fun `Donation is collected when test result is POSITIVE`() { runBlockingTest { every { testResultSettings.testScannedAfterConsent } returns mockFlowPreference(true) - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_POSITIVE) + every { testResultSettings.testResultAtRegistration } returns + mockFlowPreference(CoronaTestResult.PCR_POSITIVE) every { testResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(baseTime) val donation = @@ -137,7 +141,8 @@ class AnalyticsPCRTestResultTest : BaseTest() { fun `Donation is collected when test result is NEGATIVE`() { runBlockingTest { every { testResultSettings.testScannedAfterConsent } returns mockFlowPreference(true) - every { testResultSettings.testResultAtRegistration } returns mockFlowPreference(CoronaTestResult.PCR_NEGATIVE) + every { testResultSettings.testResultAtRegistration } returns + mockFlowPreference(CoronaTestResult.PCR_NEGATIVE) every { testResultSettings.finalTestResultReceivedAt } returns mockFlowPreference(baseTime) val donation = diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveyUrlProviderTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveyUrlProviderTest.kt index c12cda95a..c6074c815 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveyUrlProviderTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveyUrlProviderTest.kt @@ -29,9 +29,11 @@ internal class SurveyUrlProviderTest { @Test fun `provideUrl() should provide correct Url`() = runBlockingTest { val otp = UUID.randomUUID() - coEvery { appConfigProvider.getAppConfig().survey.surveyOnHighRiskUrl } returns "http://www.example.com".toHttpUrl() + coEvery { appConfigProvider.getAppConfig().survey.surveyOnHighRiskUrl } returns + "http://www.example.com".toHttpUrl() - createInstance().provideUrl(Surveys.Type.HIGH_RISK_ENCOUNTER, otp) shouldBe "http://www.example.com/?queryParamNameOtp=$otp" + createInstance().provideUrl(Surveys.Type.HIGH_RISK_ENCOUNTER, otp) shouldBe + "http://www.example.com/?queryParamNameOtp=$otp" } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveysTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveysTest.kt index 5b6ea68da..466990387 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveysTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/survey/SurveysTest.kt @@ -67,7 +67,7 @@ internal class SurveysTest : BaseTest() { } @Test - fun `isConsentNeeded() should return Needed when an authorized otp was invalidated due to a risk change from high to low risk`() = + fun `isConsentNeeded() returns Needed when an auth-otp was invalidated due to a risk change from high to low`() = runBlockingTest { every { oneTimePasswordRepo.otpAuthorizationResult } returns OTPAuthorizationResult( UUID.randomUUID(), diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/HourPackageSyncToolTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/HourPackageSyncToolTest.kt index 1f5590a38..4eededb29 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/HourPackageSyncToolTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/HourPackageSyncToolTest.kt @@ -51,10 +51,13 @@ class HourPackageSyncToolTest : CommonSyncToolTest() { mockCachedHour("EUR".loc, "2020-01-04".day, "01:00".hour) val instance = createInstance() - instance.syncMissingHourPackages(listOf("EUR".loc), false) shouldBe BaseKeyPackageSyncTool.SyncResult( - successful = true, - newPackages = keyRepoData.values.filter { it.info.type == Type.LOCATION_HOUR && it.info.hour != "01:00".hour } - ) + instance.syncMissingHourPackages(listOf("EUR".loc), false) shouldBe + BaseKeyPackageSyncTool.SyncResult( + successful = true, + newPackages = keyRepoData.values.filter { + it.info.type == Type.LOCATION_HOUR && it.info.hour != "01:00".hour + } + ) coVerifySequence { configProvider.getAppConfig() @@ -93,10 +96,13 @@ class HourPackageSyncToolTest : CommonSyncToolTest() { ) val instance = createInstance() - instance.syncMissingHourPackages(listOf("EUR".loc), false) shouldBe BaseKeyPackageSyncTool.SyncResult( - successful = true, - newPackages = keyRepoData.values.filter { it.info.type == Type.LOCATION_HOUR && it.info.hour != "01:00".hour } - ) + instance.syncMissingHourPackages(listOf("EUR".loc), false) shouldBe + BaseKeyPackageSyncTool.SyncResult( + successful = true, + newPackages = keyRepoData.values.filter { + it.info.type == Type.LOCATION_HOUR && it.info.hour != "01:00".hour + } + ) coVerifySequence { configProvider.getAppConfig() @@ -156,10 +162,13 @@ class HourPackageSyncToolTest : CommonSyncToolTest() { } val instance = createInstance() - instance.syncMissingHourPackages(listOf("EUR".loc), false) shouldBe BaseKeyPackageSyncTool.SyncResult( - successful = false, - newPackages = keyRepoData.values.filter { it.info.type == Type.LOCATION_HOUR && it.info.hour != "01:00".hour } - ) + instance.syncMissingHourPackages(listOf("EUR".loc), false) shouldBe + BaseKeyPackageSyncTool.SyncResult( + successful = false, + newPackages = keyRepoData.values.filter { + it.info.type == Type.LOCATION_HOUR && it.info.hour != "01:00".hour + } + ) coVerifySequence { configProvider.getAppConfig() diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/ExposureDetectionTrackerExtensionsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/ExposureDetectionTrackerExtensionsTest.kt index beb1bd1ef..2290a980f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/ExposureDetectionTrackerExtensionsTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/ExposureDetectionTrackerExtensionsTest.kt @@ -8,7 +8,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runBlockingTest import org.joda.time.Instant -import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -26,10 +25,6 @@ class ExposureDetectionTrackerExtensionsTest : BaseTest() { every { tracker.calculations } returns fakeCalculations } - @AfterEach - fun teardown() { - } - private fun createFakeCalculation( startedAt: Instant, result: TrackedExposureDetection.Result? = TrackedExposureDetection.Result.NO_MATCHES diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/diagnosiskeyprovider/DefaultDiagnosisKeyProviderTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/diagnosiskeyprovider/DefaultDiagnosisKeyProviderTest.kt index 82f99876f..0772e14d3 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/diagnosiskeyprovider/DefaultDiagnosisKeyProviderTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/diagnosiskeyprovider/DefaultDiagnosisKeyProviderTest.kt @@ -42,7 +42,8 @@ class DefaultDiagnosisKeyProviderTest : BaseTest() { coEvery { googleENFClient.provideDiagnosisKeys(any<List<File>>()) } returns MockGMSTask.forValue(null) - coEvery { googleENFClient.provideDiagnosisKeys(any<DiagnosisKeyFileProvider>()) } returns MockGMSTask.forValue(null) + coEvery { googleENFClient.provideDiagnosisKeys(any<DiagnosisKeyFileProvider>()) } returns + MockGMSTask.forValue(null) coEvery { enfVersion.requireMinimumVersion(any()) } returns Unit } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tekhistory/DefaultTEKHistoryProviderTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tekhistory/DefaultTEKHistoryProviderTest.kt index 129e48800..097ec369f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tekhistory/DefaultTEKHistoryProviderTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tekhistory/DefaultTEKHistoryProviderTest.kt @@ -315,7 +315,8 @@ class DefaultTEKHistoryProviderTest : BaseTest() { val mockTEK = mockk<TemporaryExposureKey>() every { client.temporaryExposureKeyHistory } returns MockGMSTask.forValue(listOf(mockTEK)) every { client.requestPreAuthorizedTemporaryExposureKeyHistory() } returns MockGMSTask.forValue(null) - every { client.requestPreAuthorizedTemporaryExposureKeyRelease() } returns MockGMSTask.forError(RuntimeException()) + every { client.requestPreAuthorizedTemporaryExposureKeyRelease() } returns + MockGMSTask.forError(RuntimeException()) val onTEKHistoryAvailable = mockk<(List<TemporaryExposureKey>) -> Unit>(relaxed = true) val onPermissionRequired = mockk<(Status) -> Unit>(relaxed = true) @@ -342,7 +343,8 @@ class DefaultTEKHistoryProviderTest : BaseTest() { coEvery { enfVersion.isAtLeast(ENFVersion.V1_8) } returns true every { client.temporaryExposureKeyHistory } returns MockGMSTask.forError(IllegalStateException()) every { client.requestPreAuthorizedTemporaryExposureKeyHistory() } returns MockGMSTask.forValue(null) - every { client.requestPreAuthorizedTemporaryExposureKeyRelease() } returns MockGMSTask.forError(RuntimeException()) + every { client.requestPreAuthorizedTemporaryExposureKeyRelease() } returns + MockGMSTask.forError(RuntimeException()) runBlockingTest { shouldThrow<IllegalStateException> { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tracing/DefaultTracingStatusTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tracing/DefaultTracingStatusTest.kt index 4c4b84d92..f5c43b039 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tracing/DefaultTracingStatusTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/tracing/DefaultTracingStatusTest.kt @@ -139,11 +139,7 @@ class DefaultTracingStatusTest : BaseTest() { val tracingStatus = mockk<TracingStatus>().apply { every { isTracingEnabled } returns enabledFlow every { setTracing(any(), any(), any(), any()) } answers { - val enabled = arg<Boolean>(0) val onSuccess = arg<(Boolean) -> Unit>(1) - val onError = arg<(Throwable) -> Unit>(2) - val onPermissionRequired = arg<(Status) -> Unit>(3) - onSuccess(false) } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/windows/ExposureWindowsCalculationTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/windows/ExposureWindowsCalculationTest.kt index 4668c0e16..60b23979a 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/windows/ExposureWindowsCalculationTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/windows/ExposureWindowsCalculationTest.kt @@ -19,7 +19,13 @@ import de.rki.coronawarnapp.nearby.windows.entities.configuration.JsonTrlFilter import de.rki.coronawarnapp.risk.DefaultRiskLevels import de.rki.coronawarnapp.risk.result.EwAggregatedRiskResult import de.rki.coronawarnapp.risk.result.RiskResult -import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.TransmissionRiskValueMapping +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.MinutesAtAttenuationFilter +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.MinutesAtAttenuationWeight +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.Range +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.TrlFilter +import de.rki.coronawarnapp.server.protocols.internal.v2.RiskCalculationParametersOuterClass.TransmissionRiskLevelEncoding import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.serialization.fromJson import io.kotest.matchers.ints.shouldBeGreaterThan @@ -128,10 +134,14 @@ class ExposureWindowsCalculationTest : BaseTest() { // 6 - Check with expected result from test case aggregatedRiskResult.totalRiskLevel.number shouldBe case.expTotalRiskLevel - aggregatedRiskResult.mostRecentDateWithHighRisk shouldBe getTestCaseDate(case.expAgeOfMostRecentDateWithHighRiskInDays) - aggregatedRiskResult.mostRecentDateWithLowRisk shouldBe getTestCaseDate(case.expAgeOfMostRecentDateWithLowRiskInDays) - aggregatedRiskResult.totalMinimumDistinctEncountersWithHighRisk shouldBe case.expTotalMinimumDistinctEncountersWithHighRisk - aggregatedRiskResult.totalMinimumDistinctEncountersWithLowRisk shouldBe case.expTotalMinimumDistinctEncountersWithLowRisk + aggregatedRiskResult.mostRecentDateWithHighRisk shouldBe + getTestCaseDate(case.expAgeOfMostRecentDateWithHighRiskInDays) + aggregatedRiskResult.mostRecentDateWithLowRisk shouldBe + getTestCaseDate(case.expAgeOfMostRecentDateWithLowRiskInDays) + aggregatedRiskResult.totalMinimumDistinctEncountersWithHighRisk shouldBe + case.expTotalMinimumDistinctEncountersWithHighRisk + aggregatedRiskResult.totalMinimumDistinctEncountersWithLowRisk shouldBe + case.expTotalMinimumDistinctEncountersWithLowRisk } } @@ -213,56 +223,65 @@ class ExposureWindowsCalculationTest : BaseTest() { result.append("\n\n").append("----------------- \uD83D\uDEE0 CONFIGURATION \uD83D\uDEE0 -----------") result.append("\n").append("◦ Minutes At Attenuation Filters (${config.minutesAtAttenuationFilters.size})") - for (filter: RiskCalculationParametersOuterClass.MinutesAtAttenuationFilter in config.minutesAtAttenuationFilters) { + for ( + filter: MinutesAtAttenuationFilter in config.minutesAtAttenuationFilters + ) { result.append("\n\t").append("⇥ Filter") result.append(logRange(filter.attenuationRange, "Attenuation Range")) result.append(logRange(filter.dropIfMinutesInRange, "Drop If Minutes In Range")) } result.append("\n").append("◦ Minutes At Attenuation Weights (${config.minutesAtAttenuationWeights.size})") - for (weight: RiskCalculationParametersOuterClass.MinutesAtAttenuationWeight in config.minutesAtAttenuationWeights) { + for (weight: MinutesAtAttenuationWeight in config.minutesAtAttenuationWeights) { result.append("\n\t").append("⇥ Weight") result.append(logRange(weight.attenuationRange, "Attenuation Range")) result.append("\n\t\t").append("↳ Weight: ${weight.weight}") } + val mappingList = config.normalizedTimePerDayToRiskLevelMappingList result.append("\n") - .append("◦ Normalized Time Per Day To Risk Level Mapping List (${config.normalizedTimePerDayToRiskLevelMappingList.size})") - for (mapping: RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping in config.normalizedTimePerDayToRiskLevelMappingList) { + .append("◦ Normalized Time Per Day To Risk Level Mapping List (${mappingList.size})") + for (mapping: NormalizedTimeToRiskLevelMapping in mappingList) { result.append("\n\t").append("⇥ Mapping") result.append(logRange(mapping.normalizedTimeRange, "Normalized Time Range")) result.append("\n\t\t").append("↳ Risk Level: ${mapping.riskLevel}") } + val levelMapping = config.normalizedTimePerExposureWindowToRiskLevelMapping result.append("\n") - .append("◦ Normalized Time Per Exposure Window To Risk Level Mapping (${config.normalizedTimePerExposureWindowToRiskLevelMapping.size})") - for (mapping: RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping in config.normalizedTimePerExposureWindowToRiskLevelMapping) { + .append("◦ Normalized Time Per Exposure Window To Risk Level Mapping (${levelMapping.size})") + for (mapping: NormalizedTimeToRiskLevelMapping in levelMapping) { result.append("\n\t").append("⇥ Mapping") result.append(logRange(mapping.normalizedTimeRange, "Normalized Time Range")) result.append("\n\t\t").append("↳ Risk Level: ${mapping.riskLevel}") } result.append("\n").append("◦ Transmission Risk Level Encoding:") + val encoding = config.transmissionRiskLevelEncoding result.append("\n\t") - .append("↳ Infectiousness Offset High: ${config.transmissionRiskLevelEncoding.infectiousnessOffsetHigh}") + .append("↳ Infectiousness Offset High: ${encoding.infectiousnessOffsetHigh}") result.append("\n\t") - .append("↳ Infectiousness Offset Standard: ${config.transmissionRiskLevelEncoding.infectiousnessOffsetStandard}") + .append("↳ Infectiousness Offset Standard: ${encoding.infectiousnessOffsetStandard}") result.append("\n\t") - .append("↳ Report Type Offset Confirmed Clinical Diagnosis: ${config.transmissionRiskLevelEncoding.reportTypeOffsetConfirmedClinicalDiagnosis}") + .append( + "↳ Report Type Offset Confirmed Clinical Diagnosis: " + + "${encoding.reportTypeOffsetConfirmedClinicalDiagnosis}" + ) result.append("\n\t") - .append("↳ Report Type Offset Confirmed Test: ${config.transmissionRiskLevelEncoding.reportTypeOffsetConfirmedTest}") + .append("↳ Report Type Offset Confirmed Test: ${encoding.reportTypeOffsetConfirmedTest}") result.append("\n\t") - .append("↳ Report Type Offset Recursive: ${config.transmissionRiskLevelEncoding.reportTypeOffsetRecursive}") + .append("↳ Report Type Offset Recursive: ${encoding.reportTypeOffsetRecursive}") result.append("\n\t") - .append("↳ Report Type Offset Self Report: ${config.transmissionRiskLevelEncoding.reportTypeOffsetSelfReport}") + .append("↳ Report Type Offset Self Report: ${encoding.reportTypeOffsetSelfReport}") result.append("\n").append("◦ Transmission Risk Level Filters (${config.transmissionRiskLevelFilters.size})") - for (filter: RiskCalculationParametersOuterClass.TrlFilter in config.transmissionRiskLevelFilters) { + for (filter: TrlFilter in config.transmissionRiskLevelFilters) { result.append("\n\t").append("⇥ Trl Filter") result.append(logRange(filter.dropIfTrlInRange, "Drop If Trl In Range")) } - result.append("\n").appendLine("◦ Transmission Risk Value Mapping (${config.transmissionRiskValueMapping.size})") + result.append("\n") + .appendLine("◦ Transmission Risk Value Mapping (${config.transmissionRiskValueMapping.size})") for (mapping in config.transmissionRiskValueMapping) { result.append("\t").appendLine("⇥ Mapping") result.append("\t\t").append("↳ transmissionRiskLevel: ").appendLine(mapping.transmissionRiskLevel) @@ -273,7 +292,7 @@ class ExposureWindowsCalculationTest : BaseTest() { debugLog(result.toString(), LogLevel.NONE) } - private fun logRange(range: RiskCalculationParametersOuterClass.Range, rangeName: String): String { + private fun logRange(range: Range, rangeName: String): String { val builder = StringBuilder() builder.append("\n\t\t").append("⇥ $rangeName") builder.append("\n\t\t\t").append("↳ Min: ${range.min}") @@ -314,9 +333,9 @@ class ExposureWindowsCalculationTest : BaseTest() { configType = ConfigData.Type.FROM_SERVER ) - val attenuationFilters = mutableListOf<RiskCalculationParametersOuterClass.MinutesAtAttenuationFilter>() + val attenuationFilters = mutableListOf<MinutesAtAttenuationFilter>() for (jsonFilter: JsonMinutesAtAttenuationFilter in json.minutesAtAttenuationFilters) { - val filter: RiskCalculationParametersOuterClass.MinutesAtAttenuationFilter = mockk() + val filter: MinutesAtAttenuationFilter = mockk() every { filter.attenuationRange.min } returns jsonFilter.attenuationRange.min every { filter.attenuationRange.max } returns jsonFilter.attenuationRange.max every { filter.attenuationRange.minExclusive } returns jsonFilter.attenuationRange.minExclusive @@ -329,9 +348,9 @@ class ExposureWindowsCalculationTest : BaseTest() { } every { testConfig.minutesAtAttenuationFilters } returns attenuationFilters - val attenuationWeights = mutableListOf<RiskCalculationParametersOuterClass.MinutesAtAttenuationWeight>() + val attenuationWeights = mutableListOf<MinutesAtAttenuationWeight>() for (jsonWeight: JsonMinutesAtAttenuationWeight in json.minutesAtAttenuationWeights) { - val weight: RiskCalculationParametersOuterClass.MinutesAtAttenuationWeight = mockk() + val weight: MinutesAtAttenuationWeight = mockk() every { weight.attenuationRange.min } returns jsonWeight.attenuationRange.min every { weight.attenuationRange.max } returns jsonWeight.attenuationRange.max every { weight.attenuationRange.minExclusive } returns jsonWeight.attenuationRange.minExclusive @@ -342,10 +361,10 @@ class ExposureWindowsCalculationTest : BaseTest() { every { testConfig.minutesAtAttenuationWeights } returns attenuationWeights val normalizedTimePerDayToRiskLevelMapping = - mutableListOf<RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping>() + mutableListOf<NormalizedTimeToRiskLevelMapping>() for (jsonMapping: JsonNormalizedTimeToRiskLevelMapping in json.normalizedTimePerDayToRiskLevelMapping) { - val mapping: RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping = mockk() - every { mapping.riskLevel } returns RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.forNumber( + val mapping: NormalizedTimeToRiskLevelMapping = mockk() + every { mapping.riskLevel } returns NormalizedTimeToRiskLevelMapping.RiskLevel.forNumber( jsonMapping.riskLevel ) every { mapping.normalizedTimeRange.min } returns jsonMapping.normalizedTimeRange.min @@ -357,10 +376,10 @@ class ExposureWindowsCalculationTest : BaseTest() { every { testConfig.normalizedTimePerDayToRiskLevelMappingList } returns normalizedTimePerDayToRiskLevelMapping val normalizedTimePerExposureWindowToRiskLevelMapping = - mutableListOf<RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping>() + mutableListOf<NormalizedTimeToRiskLevelMapping>() for (jsonMapping: JsonNormalizedTimeToRiskLevelMapping in json.normalizedTimePerEWToRiskLevelMapping) { - val mapping: RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping = mockk() - every { mapping.riskLevel } returns RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.forNumber( + val mapping: NormalizedTimeToRiskLevelMapping = mockk() + every { mapping.riskLevel } returns NormalizedTimeToRiskLevelMapping.RiskLevel.forNumber( jsonMapping.riskLevel ) every { mapping.normalizedTimeRange.min } returns jsonMapping.normalizedTimeRange.min @@ -369,20 +388,22 @@ class ExposureWindowsCalculationTest : BaseTest() { every { mapping.normalizedTimeRange.maxExclusive } returns jsonMapping.normalizedTimeRange.maxExclusive normalizedTimePerExposureWindowToRiskLevelMapping.add(mapping) } - every { testConfig.normalizedTimePerExposureWindowToRiskLevelMapping } returns normalizedTimePerExposureWindowToRiskLevelMapping + every { testConfig.normalizedTimePerExposureWindowToRiskLevelMapping } returns + normalizedTimePerExposureWindowToRiskLevelMapping - val trlEncoding: RiskCalculationParametersOuterClass.TransmissionRiskLevelEncoding = mockk() + val trlEncoding: TransmissionRiskLevelEncoding = mockk() every { trlEncoding.infectiousnessOffsetHigh } returns json.trlEncoding.infectiousnessOffsetHigh every { trlEncoding.infectiousnessOffsetStandard } returns json.trlEncoding.infectiousnessOffsetStandard - every { trlEncoding.reportTypeOffsetConfirmedClinicalDiagnosis } returns json.trlEncoding.reportTypeOffsetConfirmedClinicalDiagnosis + every { trlEncoding.reportTypeOffsetConfirmedClinicalDiagnosis } returns + json.trlEncoding.reportTypeOffsetConfirmedClinicalDiagnosis every { trlEncoding.reportTypeOffsetConfirmedTest } returns json.trlEncoding.reportTypeOffsetConfirmedTest every { trlEncoding.reportTypeOffsetRecursive } returns json.trlEncoding.reportTypeOffsetRecursive every { trlEncoding.reportTypeOffsetSelfReport } returns json.trlEncoding.reportTypeOffsetSelfReport every { testConfig.transmissionRiskLevelEncoding } returns trlEncoding - val trlFilters = mutableListOf<RiskCalculationParametersOuterClass.TrlFilter>() + val trlFilters = mutableListOf<TrlFilter>() for (jsonFilter: JsonTrlFilter in json.trlFilters) { - val filter: RiskCalculationParametersOuterClass.TrlFilter = mockk() + val filter: TrlFilter = mockk() every { filter.dropIfTrlInRange.min } returns jsonFilter.dropIfTrlInRange.min every { filter.dropIfTrlInRange.max } returns jsonFilter.dropIfTrlInRange.max every { filter.dropIfTrlInRange.minExclusive } returns jsonFilter.dropIfTrlInRange.minExclusive @@ -392,9 +413,9 @@ class ExposureWindowsCalculationTest : BaseTest() { every { testConfig.transmissionRiskLevelFilters } returns trlFilters val transmissionRiskValueMapping = - mutableListOf<RiskCalculationParametersOuterClass.TransmissionRiskValueMapping>() + mutableListOf<TransmissionRiskValueMapping>() for (jsonMapping: JsonTransmissionRiskValueMapping in json.transmissionRiskValueMapping) { - val mapping: RiskCalculationParametersOuterClass.TransmissionRiskValueMapping = mockk() + val mapping: TransmissionRiskValueMapping = mockk() mapping.run { every { transmissionRiskLevel } returns jsonMapping.transmissionRiskLevel every { transmissionRiskValue } returns jsonMapping.transmissionRiskValue @@ -408,7 +429,8 @@ class ExposureWindowsCalculationTest : BaseTest() { val exposureWindow: ExposureWindow = mockk() every { exposureWindow.calibrationConfidence } returns json.calibrationConfidence - every { exposureWindow.dateMillisSinceEpoch } returns timeStamper.nowUTC.millis - (DateTimeConstants.MILLIS_PER_DAY * json.ageInDays).toLong() + every { exposureWindow.dateMillisSinceEpoch } returns + timeStamper.nowUTC.millis - (DateTimeConstants.MILLIS_PER_DAY * json.ageInDays).toLong() every { exposureWindow.infectiousness } returns json.infectiousness every { exposureWindow.reportType } returns json.reportType every { exposureWindow.scanInstances } returns json.scanInstances.map { scanInstance -> diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/common/CheckInExtensionTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/common/CheckInExtensionTest.kt index 885122972..8df161171 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/common/CheckInExtensionTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/common/CheckInExtensionTest.kt @@ -47,7 +47,8 @@ class CheckInExtensionTest : BaseTest() { private fun CheckIn.validateLocationName() { locationName shouldBe when (traceLocationStart != null && traceLocationEnd != null) { - true -> "$description, $address, ${traceLocationStart?.toPrettyDate()} - ${traceLocationEnd?.toPrettyDate()}" + true -> + "$description, $address, ${traceLocationStart?.toPrettyDate()} - ${traceLocationEnd?.toPrettyDate()}" else -> "$description, $address" } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base32UrlProvider.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base32UrlProvider.kt index eb5652687..6dc940315 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base32UrlProvider.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base32UrlProvider.kt @@ -12,6 +12,7 @@ import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import java.util.stream.Stream +@Suppress("MaxLineLength") class Base32UrlProvider : ArgumentsProvider { override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { return Stream.of( diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base64UrlProvider.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base64UrlProvider.kt index b45bd725f..3e49160e0 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base64UrlProvider.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/qrcode/Base64UrlProvider.kt @@ -16,8 +16,8 @@ class Base64UrlProvider : ArgumentsProvider { override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { return Stream.of( Arguments.of( - "https://e.coronawarn.app?v=1#CAESLAgBEhFNeSBCaXJ0aGRheSBQYXJ0eRoLYXQgbXkgcGxhY2Uo04ekATD3h6QBGmoIARJgO" + - "MTa6eYSiaDv8lW13xdYEvGHOZ1EYTiFSxt51HEoPCD7CNnvCUiIYPhax1MpkN0UfNClCm9ZWYy0JH01CDVD9eq-vox" + + "https://e.coronawarn.app?v=1#CAESLAgBEhFNeSBCaXJ0aGRheSBQYXJ0eRoLYXQgbXkgcGxhY2Uo04ekATD3h6QBGmoIAR" + + "JgOMTa6eYSiaDv8lW13xdYEvGHOZ1EYTiFSxt51HEoPCD7CNnvCUiIYPhax1MpkN0UfNClCm9ZWYy0JH01CDVD9eq-vox" + "Q1EcFJQkEIujVwoCNK0MNGuDK1ayjGxeDc4UDGgQxMjM0IgQIARAC", QRCodePayload.newBuilder() .setVersion(1) @@ -44,8 +44,8 @@ class Base64UrlProvider : ArgumentsProvider { .build() ), Arguments.of( - "https://e.coronawarn.app?v=1#CAESIAgBEg1JY2VjcmVhbSBTaG9wGg1NYWluIFN0cmVldCAxGmoIARJgOMTa6eYSiaDv8lW1" + - "3xdYEvGHOZ1EYTiFSxt51HEoPCD7CNnvCUiIYPhax1MpkN0UfNClCm9ZWYy0JH01CDVD9eq-voxQ" + + "https://e.coronawarn.app?v=1#CAESIAgBEg1JY2VjcmVhbSBTaG9wGg1NYWluIFN0cmVldCAxGmoIARJgOMTa6eYSiaDv8l" + + "W13xdYEvGHOZ1EYTiFSxt51HEoPCD7CNnvCUiIYPhax1MpkN0UfNClCm9ZWYy0JH01CDVD9eq-voxQ" + "1EcFJQkEIujVwoCNK0MNGuDK1ayjGxeDc4UDGgQxMjM0IgYIARABGAo", QRCodePayload.newBuilder() .setVersion(1) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/locations/server/QrCodePosterTemplateServerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/locations/server/QrCodePosterTemplateServerTest.kt index a23b791c1..998e1a714 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/locations/server/QrCodePosterTemplateServerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/locations/server/QrCodePosterTemplateServerTest.kt @@ -124,21 +124,22 @@ internal class QrCodePosterTemplateServerTest : BaseTest() { .build()*/ private val POSTER_BUNDLE = ( - "504b03040a0000000800685588525c24ae70900100000e0300000a0000006578706f72742e62696e6d52cd4ac3401006410a0bde2c" + - "28280c9442556a9226db7aa8155a5b04154b1af0507bd89a6d8da45949b6507d099fc293275fa13e840fe0c527f0ec6e7e6ada" + - "744f33df7edf7c33b38bbe378bddf34e593bd65071fe36fff87c47480315d8f01101d4eba058cf4f149416e1c465638189a374" + - "c9980650113c53208d06a29e2d15a8b2461a9263e1a56307d0d7a57010432d36f5386871764d6d8734d90cfaaa20e9aa0a9a61" + - "0c964df4b449da25aa21639f8a9a497f2166d2804dfdfba493a8c10ef378922f302d8d246864b2ca8f8fd29b0e794890b48c5e" + - "329a24a0522d28ce840665934d88b74a1433aecd16915896c7c5680118d9dd1b4bbbbfa2de983f00c69212709f9289b8695a61" + - "2531246827608dc24c6edab2c3b074415d97c12df35dfb002c59ac6d4987b842e235f3e908a98091ba3850c558c7308205261c" + - "a21bef1fabd5329856cbf20c9ce2719f382ef593f7361913ff25fdb63de7858a5e201a95f83c6c0f57312a16db371d94475f85" + - "c6feddebfc147e7287bb5b1b47b946feb7b477b663c37609557285c8f50f504b03040a00000008006855885218d81ad88f0000" + - "008a0000000a0000006578706f72742e736967018a0075ff0a87010a380a1864652e726b692e636f726f6e617761726e617070" + - "2d6465761a02763122033236322a13312e322e3834302e31303034352e342e332e3210011801224730450220148d01176d9be9" + - "8fa78ca1b0cad0b8b12033f35a43cb7d10369536c233701fff022100ed7c748e7f8e82c6a98ead3a19f2041b1ec090268e3ae1" + - "5aa146bd0d567617c7504b01020a000a0000000800685588525c24ae70900100000e0300000a0000000000000000000000a401" + - "000000006578706f72742e62696e504b01020a000a00000008006855885218d81ad88f0000008a0000000a0000000000000000" + - "000000a401b80100006578706f72742e736967504b05060000000002000200700000006f0200000000" + "504b03040a0000000800685588525c24ae70900100000e0300000a0000006578706f72742e62696e6d52cd4ac3401006410" + + "a0bde2c28280c9442556a9226db7aa8155a5b04154b1af0507bd89a6d8da45949b6507d099fc293275fa13e840fe0c5" + + "27f0ec6e7e6ada744f33df7edf7c33b38bbe378bddf34e593bd65071fe36fff87c47480315d8f01101d4eba058cf4f1" + + "49416e1c465638189a374c9980650113c53208d06a29e2d15a8b2461a9263e1a56307d0d7a57010432d36f538687176" + + "4d6d8734d90cfaaa20e9aa0a9a610c964df4b449da25aa21639f8a9a497f2166d2804dfdfba493a8c10ef378922f302" + + "d8d246864b2ca8f8fd29b0e794890b48c5e329a24a0522d28ce840665934d88b74a1433aecd16915896c7c5680118d9" + + "dd1b4bbbbfa2de983f00c69212709f9289b8695a612531246827608dc24c6edab2c3b074415d97c12df35dfb002c59a" + + "c6d4987b842e235f3e908a98091ba3850c558c7308205261ca21bef1fabd5329856cbf20c9ce2719f382ef593f73619" + + "13ff25fdb63de7858a5e201a95f83c6c0f57312a16db371d94475f85c6feddebfc147e7287bb5b1b47b946feb7b477b" + + "663c37609557285c8f50f504b03040a00000008006855885218d81ad88f0000008a0000000a0000006578706f72742e" + + "736967018a0075ff0a87010a380a1864652e726b692e636f726f6e617761726e6170702d6465761a027631220332363" + + "22a13312e322e3834302e31303034352e342e332e3210011801224730450220148d01176d9be98fa78ca1b0cad0b8b1" + + "2033f35a43cb7d10369536c233701fff022100ed7c748e7f8e82c6a98ead3a19f2041b1ec090268e3ae15aa146bd0d5" + + "67617c7504b01020a000a0000000800685588525c24ae70900100000e0300000a0000000000000000000000a4010000" + + "00006578706f72742e62696e504b01020a000a00000008006855885218d81ad88f0000008a0000000a0000000000000" + + "000000000a401b80100006578706f72742e736967504b05060000000002000200700000006f0200000000" ).decodeHex() } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/calculation/CheckInWarningMatcherTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/calculation/CheckInWarningMatcherTest.kt index 52e215794..45545787a 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/calculation/CheckInWarningMatcherTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/calculation/CheckInWarningMatcherTest.kt @@ -182,6 +182,7 @@ class CheckInWarningMatcherTest : BaseTest() { endDateStr = "2021-03-04T10:12+01:00" ) + @Suppress("TooGenericExceptionThrown") val warningPackage = object : TraceWarningPackage { override suspend fun extractWarnings(): List<TraceWarning.TraceTimeIntervalWarning> { throw Exception() @@ -219,6 +220,7 @@ class CheckInWarningMatcherTest : BaseTest() { endDateStr = "2021-03-04T10:12+01:00" ) + @Suppress("TooGenericExceptionThrown") val warningPackage1 = object : TraceWarningPackage { override suspend fun extractWarnings() = throw Exception() diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepositoryTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepositoryTest.kt index ab4464a2e..b29dde3c5 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepositoryTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepositoryTest.kt @@ -103,9 +103,10 @@ class PresenceTracingRiskRepositoryTest : BaseTest() { localDateUtc = now.minus(100000).toLocalDateUtc(), riskState = RiskState.LOW_RISK ) - coEvery { presenceTracingRiskCalculator.calculateNormalizedTime(listOf(entity2.toCheckInWarningOverlap())) } returns listOf( - time - ) + coEvery { + presenceTracingRiskCalculator.calculateNormalizedTime(listOf(entity2.toCheckInWarningOverlap())) + } returns listOf(time) + coEvery { presenceTracingRiskCalculator.calculateCheckInRiskPerDay(listOf(time)) } returns listOf(riskPerDay) runBlockingTest { val riskStates = createInstance().traceLocationCheckInRiskStates.first() diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorageTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorageTest.kt index 38b4421e2..c3f5cbf6e 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorageTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorageTest.kt @@ -378,7 +378,8 @@ class BaseRiskLevelStorageTest : BaseTest() { ) ) ) - every { presenceTracingRiskRepository.presenceTracingDayRisk } returns flowOf(listOf(testPresenceTracingDayRisk)) + every { presenceTracingRiskRepository.presenceTracingDayRisk } returns + flowOf(listOf(testPresenceTracingDayRisk)) every { riskResultTables.latestAndLastSuccessful() } returns flowOf(listOf(testRiskLevelResultDao)) every { exposureWindowTables.getWindowsForResult(any()) } returns flowOf(listOf(testExposureWindowDaoWrapper)) @@ -437,7 +438,8 @@ class BaseRiskLevelStorageTest : BaseTest() { numberOfDaysWithHighRisk = 6 ) ) - every { presenceTracingRiskRepository.presenceTracingDayRisk } returns flowOf(listOf(testPresenceTracingDayRisk)) + every { presenceTracingRiskRepository.presenceTracingDayRisk } returns + flowOf(listOf(testPresenceTracingDayRisk)) every { riskResultTables.latestAndLastSuccessful() } returns flowOf(listOf(ewResultDao1, ewResultDao2)) every { exposureWindowTables.getWindowsForResult(any()) } returns flowOf(listOf(testExposureWindowDaoWrapper)) @@ -496,7 +498,8 @@ class BaseRiskLevelStorageTest : BaseTest() { numberOfDaysWithHighRisk = 6 ) ) - every { presenceTracingRiskRepository.presenceTracingDayRisk } returns flowOf(listOf(testPresenceTracingDayRisk)) + every { presenceTracingRiskRepository.presenceTracingDayRisk } returns + flowOf(listOf(testPresenceTracingDayRisk)) every { riskResultTables.latestAndLastSuccessful() } returns flowOf(listOf(ewResultDao1, ewResultDao2)) every { exposureWindowTables.getWindowsForResult(any()) } returns flowOf(listOf(testExposureWindowDaoWrapper)) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/internal/PersistedRiskResultDaoTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/internal/PersistedRiskResultDaoTest.kt index 52e7ac660..2d080c2e4 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/internal/PersistedRiskResultDaoTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/storage/internal/PersistedRiskResultDaoTest.kt @@ -36,7 +36,8 @@ class PersistedRiskResultDaoTest : BaseTest() { failureReason shouldBe null ewAggregatedRiskResult shouldNotBe null ewAggregatedRiskResult?.apply { - totalRiskLevel shouldBe RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.LOW + totalRiskLevel shouldBe + RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.LOW totalMinimumDistinctEncountersWithLowRisk shouldBe 89 totalMinimumDistinctEncountersWithHighRisk shouldBe 59 mostRecentDateWithLowRisk shouldNotBe null @@ -71,7 +72,8 @@ class PersistedRiskResultDaoTest : BaseTest() { failureReason shouldBe null ewAggregatedRiskResult shouldNotBe null ewAggregatedRiskResult?.apply { - totalRiskLevel shouldBe RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.LOW + totalRiskLevel shouldBe + RiskCalculationParametersOuterClass.NormalizedTimeToRiskLevelMapping.RiskLevel.LOW totalMinimumDistinctEncountersWithLowRisk shouldBe 89 totalMinimumDistinctEncountersWithHighRisk shouldBe 59 mostRecentDateWithLowRisk shouldNotBe null diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/statistics/source/StatisticsServerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/statistics/source/StatisticsServerTest.kt index f1b7acf65..56cbd7bf1 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/statistics/source/StatisticsServerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/statistics/source/StatisticsServerTest.kt @@ -82,26 +82,24 @@ class StatisticsServerTest : BaseIOTest() { } companion object { - private val STATS_ZIP = - ( - "504b03041400080808008d4a2f520000000000000000000000000a0000006578706f72742e736967018b0074ff0a88010a380a" + - "1864652e726b692e636f726f6e617761726e6170702d6465761a02763122033236322a13312e322e3834302e3130303435" + - "2e342e332e321001180122483046022100f363cc4813367bdd2fa03c91fc49c3521abf2db86ec8f5836f97f5d13f915285" + - "022100e8a51c68ece56ccc44de41cee75d766adb5f1d688d1773875dc1c6944bc2a1de504b0708a4db7bfc900000008b00" + - "0000504b03041400080808008d4a2f520000000000000000000000000a0000006578706f72742e62696ee3626164666211" + - "32e5e2e060146898fcef3fab103707a3200308dcb8ea20c4cfc104e6386cb9e4a0c0a4c10c9465060b1c5a69e728240bd4" + - "c604d52608d41621e1f3e19e73928304a302b30613d8546674535f34204c6560a8725060d460849bfac18d11622a8b40c3" + - "93c750538376c8b5be0efc602fc104520b00504b070867e7aa477b000000b2000000504b010214001400080808008d4a2f" + - "52a4db7bfc900000008b0000000a00000000000000000000000000000000006578706f72742e736967504b010214001400" + - "080808008d4a2f5267e7aa477b000000b20000000a00000000000000000000000000c80000006578706f72742e62696e50" + - "4b05060000000002000200700000007b0100000000" - ).decodeHex() - private val STATS_PROTO = - ( - "0a040103020412350a080801108093feff05120b0801110000000000d8d540120f0802110000000040b4d24020022803120b08" + - "031100000000c2a93e41121d0a080802108093feff05121108011158184cf0de43624018012003280212350a0808031080" + - "93feff05120b0801110000000000e88040120f0802110000000000007a4020012801120b08031100000000f0460141121d" + - "0a0808041080e4e3ff05121108011152b81e85eb51f03f180220012801" - ).decodeHex().toByteArray() + private val STATS_ZIP = ( + "504b03041400080808008d4a2f520000000000000000000000000a0000006578706f72742e736967018b0074ff0a88010a380a" + + "1864652e726b692e636f726f6e617761726e6170702d6465761a02763122033236322a13312e322e3834302e3130303435" + + "2e342e332e321001180122483046022100f363cc4813367bdd2fa03c91fc49c3521abf2db86ec8f5836f97f5d13f915285" + + "022100e8a51c68ece56ccc44de41cee75d766adb5f1d688d1773875dc1c6944bc2a1de504b0708a4db7bfc900000008b00" + + "0000504b03041400080808008d4a2f520000000000000000000000000a0000006578706f72742e62696ee3626164666211" + + "32e5e2e060146898fcef3fab103707a3200308dcb8ea20c4cfc104e6386cb9e4a0c0a4c10c9465060b1c5a69e728240bd4" + + "c604d52608d41621e1f3e19e73928304a302b30613d8546674535f34204c6560a8725060d460849bfac18d11622a8b40c3" + + "93c750538376c8b5be0efc602fc104520b00504b070867e7aa477b000000b2000000504b010214001400080808008d4a2f" + + "52a4db7bfc900000008b0000000a00000000000000000000000000000000006578706f72742e736967504b010214001400" + + "080808008d4a2f5267e7aa477b000000b20000000a00000000000000000000000000c80000006578706f72742e62696e50" + + "4b05060000000002000200700000007b0100000000" + ).decodeHex() + private val STATS_PROTO = ( + "0a040103020412350a080801108093feff05120b0801110000000000d8d540120f0802110000000040b4d24020022803120b08" + + "031100000000c2a93e41121d0a080802108093feff05121108011158184cf0de43624018012003280212350a0808031080" + + "93feff05120b0801110000000000e88040120f0802110000000000007a4020012801120b08031100000000f0460141121d" + + "0a0808041080e4e3ff05121108011152b81e85eb51f03f180220012801" + ).decodeHex().toByteArray() } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/tracing/ui/settings/TracingSettingsStateTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/tracing/ui/settings/TracingSettingsStateTest.kt index 9c4280d16..cad395181 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/tracing/ui/settings/TracingSettingsStateTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/tracing/ui/settings/TracingSettingsStateTest.kt @@ -23,10 +23,14 @@ class TracingSettingsStateTest : BaseTest() { @Test fun `state mapping`() { - GeneralTracingStatus.Status.TRACING_ACTIVE.toTracingSettingsState() shouldBe TracingSettingsState.TracingActive - GeneralTracingStatus.Status.TRACING_INACTIVE.toTracingSettingsState() shouldBe TracingSettingsState.TracingInactive - GeneralTracingStatus.Status.LOCATION_DISABLED.toTracingSettingsState() shouldBe TracingSettingsState.LocationDisabled - GeneralTracingStatus.Status.BLUETOOTH_DISABLED.toTracingSettingsState() shouldBe TracingSettingsState.BluetoothDisabled + GeneralTracingStatus.Status.TRACING_ACTIVE.toTracingSettingsState() shouldBe + TracingSettingsState.TracingActive + GeneralTracingStatus.Status.TRACING_INACTIVE.toTracingSettingsState() shouldBe + TracingSettingsState.TracingInactive + GeneralTracingStatus.Status.LOCATION_DISABLED.toTracingSettingsState() shouldBe + TracingSettingsState.LocationDisabled + GeneralTracingStatus.Status.BLUETOOTH_DISABLED.toTracingSettingsState() shouldBe + TracingSettingsState.BluetoothDisabled } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/settings/start/SettingsTracingStateTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/settings/start/SettingsTracingStateTest.kt index 3605b67d7..a2bd7341a 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/settings/start/SettingsTracingStateTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/settings/start/SettingsTracingStateTest.kt @@ -24,10 +24,14 @@ class SettingsTracingStateTest : BaseTest() { @Test fun `state mapping`() { - GeneralTracingStatus.Status.TRACING_ACTIVE.toSettingsTracingState() shouldBe SettingsTracingState.TracingActive - GeneralTracingStatus.Status.TRACING_INACTIVE.toSettingsTracingState() shouldBe SettingsTracingState.TracingInActive - GeneralTracingStatus.Status.LOCATION_DISABLED.toSettingsTracingState() shouldBe SettingsTracingState.LocationDisabled - GeneralTracingStatus.Status.BLUETOOTH_DISABLED.toSettingsTracingState() shouldBe SettingsTracingState.BluetoothDisabled + GeneralTracingStatus.Status.TRACING_ACTIVE.toSettingsTracingState() shouldBe + SettingsTracingState.TracingActive + GeneralTracingStatus.Status.TRACING_INACTIVE.toSettingsTracingState() shouldBe + SettingsTracingState.TracingInActive + GeneralTracingStatus.Status.LOCATION_DISABLED.toSettingsTracingState() shouldBe + SettingsTracingState.LocationDisabled + GeneralTracingStatus.Status.BLUETOOTH_DISABLED.toSettingsTracingState() shouldBe + SettingsTracingState.BluetoothDisabled } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/submission/qrcode/scan/SubmissionQRCodeScanViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/submission/qrcode/scan/SubmissionQRCodeScanViewModelTest.kt index e55f7c277..46c6931ed 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/submission/qrcode/scan/SubmissionQRCodeScanViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ui/submission/qrcode/scan/SubmissionQRCodeScanViewModelTest.kt @@ -114,7 +114,9 @@ class SubmissionQRCodeScanViewModelTest : BaseTest() { createViewModel().startQrCodeRegistration(rawResult = "", isConsentGiven = true) verify(exactly = 1) { analyticsKeySubmissionCollector.reportAdvancedConsentGiven(CoronaTest.Type.PCR) } - verify(exactly = 0) { analyticsKeySubmissionCollector.reportAdvancedConsentGiven(CoronaTest.Type.RAPID_ANTIGEN) } + verify(exactly = 0) { + analyticsKeySubmissionCollector.reportAdvancedConsentGiven(CoronaTest.Type.RAPID_ANTIGEN) + } } @Test @@ -128,6 +130,8 @@ class SubmissionQRCodeScanViewModelTest : BaseTest() { createViewModel().startQrCodeRegistration(rawResult = "", isConsentGiven = true) verify(exactly = 1) { analyticsKeySubmissionCollector.reportAdvancedConsentGiven(CoronaTest.Type.PCR) } - verify(exactly = 0) { analyticsKeySubmissionCollector.reportAdvancedConsentGiven(CoronaTest.Type.RAPID_ANTIGEN) } + verify(exactly = 0) { + analyticsKeySubmissionCollector.reportAdvancedConsentGiven(CoronaTest.Type.RAPID_ANTIGEN) + } } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/NoPaddingTestProvider.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/NoPaddingTestProvider.kt index 4630acdca..a7d6cf3de 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/NoPaddingTestProvider.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/NoPaddingTestProvider.kt @@ -5,6 +5,7 @@ import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import java.util.stream.Stream +@Suppress("MaxLineLength") class NoPaddingTestProvider : ArgumentsProvider { override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { return Stream.of( diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/RetryMechanismTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/RetryMechanismTest.kt index dae2845e5..888fd0334 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/RetryMechanismTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/RetryMechanismTest.kt @@ -22,6 +22,7 @@ class RetryMechanismTest : BaseTest() { @BeforeEach fun setup() { MockKAnnotations.init(this) + @Suppress("TooGenericExceptionThrown") every { mockFunction.invoke() } answers { throw RuntimeException(UUID.randomUUID().toString()) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/WithPaddingTestProvider.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/WithPaddingTestProvider.kt index 0b2bcfef8..576820b24 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/WithPaddingTestProvider.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/WithPaddingTestProvider.kt @@ -4,7 +4,7 @@ import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import java.util.stream.Stream - +@Suppress("MaxLineLength") class WithPaddingTestProvider : ArgumentsProvider { override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { return Stream.of( diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/formatter/FormatterSubmissionHelperTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/formatter/FormatterSubmissionHelperTest.kt index 14bb4ab06..7dcb2736b 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/formatter/FormatterSubmissionHelperTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/formatter/FormatterSubmissionHelperTest.kt @@ -42,12 +42,18 @@ class FormatterSubmissionHelperTest : BaseTest() { every { CoronaWarnApplication.getAppContext() } returns context - every { context.getString(R.string.test_result_card_status_positive) } returns R.string.test_result_card_status_positive.toString() - every { context.getString(R.string.test_result_card_status_negative) } returns R.string.test_result_card_status_negative.toString() - every { context.getString(R.string.test_result_card_status_invalid) } returns R.string.test_result_card_status_invalid.toString() - every { context.getString(R.string.test_result_card_virus_name_text) } returns R.string.test_result_card_virus_name_text.toString() - every { context.getString(R.string.test_result_card_status_pending) } returns R.string.test_result_card_status_pending.toString() - every { context.getString(R.string.test_result_card_status_invalid) } returns R.string.test_result_card_status_invalid.toString() + every { context.getString(R.string.test_result_card_status_positive) } returns + R.string.test_result_card_status_positive.toString() + every { context.getString(R.string.test_result_card_status_negative) } returns + R.string.test_result_card_status_negative.toString() + every { context.getString(R.string.test_result_card_status_invalid) } returns + R.string.test_result_card_status_invalid.toString() + every { context.getString(R.string.test_result_card_virus_name_text) } returns + R.string.test_result_card_virus_name_text.toString() + every { context.getString(R.string.test_result_card_status_pending) } returns + R.string.test_result_card_status_pending.toString() + every { context.getString(R.string.test_result_card_status_invalid) } returns + R.string.test_result_card_status_invalid.toString() with(context) { every { getColorCompat(R.color.colorTextSemanticGreen) } returns R.color.colorTextSemanticGreen @@ -64,15 +70,22 @@ class FormatterSubmissionHelperTest : BaseTest() { every { getDrawableCompat(R.drawable.ic_test_result_illustration_negative) } returns drawable } - every { context.getString(R.string.submission_status_card_title_available) } returns R.string.submission_status_card_title_available.toString() - every { context.getString(R.string.submission_status_card_title_pending) } returns R.string.submission_status_card_title_pending.toString() - - every { context.getString(R.string.submission_status_card_body_invalid) } returns R.string.submission_status_card_body_invalid.toString() - every { context.getString(R.string.submission_status_card_body_negative) } returns R.string.submission_status_card_body_negative.toString() - every { context.getString(R.string.submission_status_card_body_positive) } returns R.string.submission_status_card_body_positive.toString() - every { context.getString(R.string.submission_status_card_body_pending) } returns R.string.submission_status_card_body_pending.toString() - - every { context.getString(R.string.submission_status_card_button_show_results) } returns R.string.submission_status_card_button_show_results.toString() + every { context.getString(R.string.submission_status_card_title_available) } returns + R.string.submission_status_card_title_available.toString() + every { context.getString(R.string.submission_status_card_title_pending) } returns + R.string.submission_status_card_title_pending.toString() + + every { context.getString(R.string.submission_status_card_body_invalid) } returns + R.string.submission_status_card_body_invalid.toString() + every { context.getString(R.string.submission_status_card_body_negative) } returns + R.string.submission_status_card_body_negative.toString() + every { context.getString(R.string.submission_status_card_body_positive) } returns + R.string.submission_status_card_body_positive.toString() + every { context.getString(R.string.submission_status_card_body_pending) } returns + R.string.submission_status_card_body_pending.toString() + + every { context.getString(R.string.submission_status_card_button_show_results) } returns + R.string.submission_status_card_button_show_results.toString() } private fun formatTestResultStatusTextBase( @@ -107,7 +120,8 @@ class FormatterSubmissionHelperTest : BaseTest() { every { SpannableStringBuilder().append(any<String>()) } returns spannableStringBuilder1 every { spannableStringBuilder1.append("\n") } returns spannableStringBuilder2 - every { context.getString(R.string.test_result_card_virus_name_text) } returns R.string.test_result_card_virus_name_text.toString() + every { context.getString(R.string.test_result_card_virus_name_text) } returns + R.string.test_result_card_virus_name_text.toString() every { spannableStringBuilder2.append( any<String>(), diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/network/NetworkStateProviderTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/network/NetworkStateProviderTest.kt index 5b7d37f41..b0e191c78 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/network/NetworkStateProviderTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/network/NetworkStateProviderTest.kt @@ -253,7 +253,9 @@ class NetworkStateProviderTest : BaseTest() { connectivityManager.getLinkProperties(network) connectivityManager.registerNetworkCallback(networkRequest, any<ConnectivityManager.NetworkCallback>()) } - verify(exactly = 0) { connectivityManager.unregisterNetworkCallback(any<ConnectivityManager.NetworkCallback>()) } + verify(exactly = 0) { + connectivityManager.unregisterNetworkCallback(any<ConnectivityManager.NetworkCallback>()) + } } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/worker/WorkerBinderTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/worker/WorkerBinderTest.kt index 063debf6e..d5ec4edc8 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/worker/WorkerBinderTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/worker/WorkerBinderTest.kt @@ -83,7 +83,8 @@ class WorkerBinderTest : BaseTest() { @Component(modules = [WorkerBinder::class, MockProvider::class]) interface WorkerTestComponent { - val factories: @JvmSuppressWildcards Map<Class<out ListenableWorker>, Provider<InjectedWorkerFactory<out ListenableWorker>>> + val factories: + @JvmSuppressWildcards Map<Class<out ListenableWorker>, Provider<InjectedWorkerFactory<out ListenableWorker>>> @Component.Factory interface Factory { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/VaccinationTestData.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/VaccinationTestData.kt index 0c5117d63..5652d7054 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/VaccinationTestData.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/VaccinationTestData.kt @@ -10,6 +10,7 @@ import de.rki.coronawarnapp.vaccination.core.repository.storage.VaccinationConta import org.joda.time.Instant import javax.inject.Inject +@Suppress("MaxLineLength") class VaccinationTestData @Inject constructor( private var qrCodeExtractor: VaccinationQRCodeExtractor, ) { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/server/valueset/VaccinationServerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/server/valueset/VaccinationServerTest.kt index 0c27822e1..1c78f8412 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/server/valueset/VaccinationServerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/vaccination/core/server/valueset/VaccinationServerTest.kt @@ -51,6 +51,7 @@ class VaccinationServerTest : BaseTest() { ) @Test + @Suppress("NestedBlockDepth") fun `valid export data`() { every { signatureValidation.hasValidSignature(any(), any()) } returns true exportZip.inputStream().use { diff --git a/Corona-Warn-App/src/test/java/testhelpers/BaseTest.kt b/Corona-Warn-App/src/test/java/testhelpers/BaseTest.kt index 3eaa6c4c8..401fa2676 100644 --- a/Corona-Warn-App/src/test/java/testhelpers/BaseTest.kt +++ b/Corona-Warn-App/src/test/java/testhelpers/BaseTest.kt @@ -5,6 +5,7 @@ import org.junit.jupiter.api.AfterAll import testhelpers.logging.JUnitTree import timber.log.Timber +@Suppress("UnnecessaryAbstractClass", "UtilityClassWithPublicConstructor") abstract class BaseTest { init { diff --git a/Corona-Warn-App/src/test/java/testhelpers/gms/MockListenableFuture.kt b/Corona-Warn-App/src/test/java/testhelpers/gms/MockListenableFuture.kt index 829b08e38..147960fa0 100644 --- a/Corona-Warn-App/src/test/java/testhelpers/gms/MockListenableFuture.kt +++ b/Corona-Warn-App/src/test/java/testhelpers/gms/MockListenableFuture.kt @@ -3,7 +3,6 @@ package testhelpers.gms import com.google.common.util.concurrent.ListenableFuture import io.mockk.every import io.mockk.mockk -import java.util.concurrent.Executor object MockListenableFuture { fun <T> forResult(result: T) = mockk<ListenableFuture<T>>().apply { @@ -14,7 +13,6 @@ object MockListenableFuture { every { cancel(any()) } returns true every { addListener(any(), any()) } answers { val listener = arg<Runnable>(0) - val executor = arg<Executor>(1) listener.run() } } diff --git a/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/nearby/modules/exposurewindow/ExposureWindowProviderTest.kt b/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/nearby/modules/exposurewindow/ExposureWindowProviderTest.kt index 07e494877..2ea8381d4 100644 --- a/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/nearby/modules/exposurewindow/ExposureWindowProviderTest.kt +++ b/Corona-Warn-App/src/testDeviceForTesters/java/de/rki/coronawarnapp/nearby/modules/exposurewindow/ExposureWindowProviderTest.kt @@ -35,7 +35,7 @@ class ExposureWindowProviderTest : BaseTestInstrumentation() { @Test fun `fake exposure windows only in tester builds`() { - val instance = createProvider() + createProvider() CWADebug.isDeviceForTestersBuild shouldBe true } } diff --git a/build.gradle b/build.gradle index ac2be4596..9e108b1ee 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { repositories { google() - jcenter() + mavenCentral() maven { url "https://plugins.gradle.org/m2/" } @@ -17,8 +17,8 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufVersion" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navVersion" - classpath "org.jlleitschuh.gradle:ktlint-gradle:9.4.1" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.16.0-RC1" + classpath "org.jlleitschuh.gradle:ktlint-gradle:10.0.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.17.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -56,7 +56,7 @@ subprojects { allprojects { repositories { google() - jcenter() + mavenCentral() } } -- GitLab