diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt index b6bcb6f1f1b..d3b45e2d445 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt @@ -13,8 +13,7 @@ import de.rki.coronawarnapp.util.ui.observe2 import de.rki.coronawarnapp.util.ui.viewBinding import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactoryProvider import de.rki.coronawarnapp.util.viewmodel.cwaViewModels -import org.joda.time.DateTimeZone -import org.joda.time.format.ISODateTimeFormat +import java.time.format.DateTimeFormatter import javax.inject.Inject @SuppressLint("SetTextI18n") @@ -25,8 +24,7 @@ class AppConfigTestFragment : Fragment(R.layout.fragment_test_appconfig), AutoIn private val binding: FragmentTestAppconfigBinding by viewBinding() - private val timeFormatter = ISODateTimeFormat.dateTime() - .withZone(DateTimeZone.forID("Europe/Berlin")) + private val timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd - HH:mm:ss") @Suppress("DEPRECATION") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -34,10 +32,10 @@ class AppConfigTestFragment : Fragment(R.layout.fragment_test_appconfig), AutoIn vm.currentConfig.observe2(this) { data -> binding.currentConfiguration.text = data.rawConfig.toString() - binding.lastUpdate.text = timeFormatter.print(data.updatedAt) + binding.lastUpdate.text = timeFormatter.format(data.updatedAt) binding.timeOffset.text = """ - ${data.localOffset.millis}ms + ${data.localOffset.toMillis()}ms configType=${data.configType} isDeviceTimeCorrect=${data.isDeviceTimeCorrect} """.trimIndent() diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/AppConfigModule.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/AppConfigModule.kt index 8cd037f01f7..bc040121162 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/AppConfigModule.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/AppConfigModule.kt @@ -22,7 +22,7 @@ import de.rki.coronawarnapp.util.di.AppContext import de.rki.coronawarnapp.util.reset.Resettable import okhttp3.Cache import okhttp3.OkHttpClient -import org.joda.time.Duration +import java.time.Duration import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.io.File @@ -43,10 +43,10 @@ object AppConfigModule { val configHttpClient = client.newBuilder().apply { cache(cache) - connectTimeout(HTTP_TIMEOUT_APPCONFIG.millis, TimeUnit.MILLISECONDS) - readTimeout(HTTP_TIMEOUT_APPCONFIG.millis, TimeUnit.MILLISECONDS) - writeTimeout(HTTP_TIMEOUT_APPCONFIG.millis, TimeUnit.MILLISECONDS) - callTimeout(HTTP_TIMEOUT_APPCONFIG.millis, TimeUnit.MILLISECONDS) + connectTimeout(HTTP_TIMEOUT_APPCONFIG.toMillis(), TimeUnit.MILLISECONDS) + readTimeout(HTTP_TIMEOUT_APPCONFIG.toMillis(), TimeUnit.MILLISECONDS) + writeTimeout(HTTP_TIMEOUT_APPCONFIG.toMillis(), TimeUnit.MILLISECONDS) + callTimeout(HTTP_TIMEOUT_APPCONFIG.toMillis(), TimeUnit.MILLISECONDS) }.build() return Retrofit.Builder() @@ -109,5 +109,5 @@ object AppConfigModule { } } -private val HTTP_TIMEOUT_APPCONFIG = Duration.standardSeconds(10) +private val HTTP_TIMEOUT_APPCONFIG = Duration.ofSeconds(10) private const val DEFAULT_CACHE_SIZE = 2 * 1024 * 1024L // 5MB diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ConfigData.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ConfigData.kt index 1da1362a184..7b7cfe98ef0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ConfigData.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ConfigData.kt @@ -1,8 +1,8 @@ package de.rki.coronawarnapp.appconfig import de.rki.coronawarnapp.appconfig.mapping.ConfigMapping -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant interface ConfigData : ConfigMapping { @@ -77,6 +77,6 @@ interface ConfigData : ConfigMapping { } companion object { - val DEVICE_TIME_GRACE_RANGE: Duration = Duration.standardHours(2) + val DEVICE_TIME_GRACE_RANGE: Duration = Duration.ofHours(2) } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CoronaTestConfig.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CoronaTestConfig.kt index f58640004f2..559b5c7fb8c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CoronaTestConfig.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CoronaTestConfig.kt @@ -1,7 +1,7 @@ package de.rki.coronawarnapp.appconfig import de.rki.coronawarnapp.appconfig.mapping.ConfigMapper -import org.joda.time.Duration +import java.time.Duration interface CoronaTestConfig { val ratParameters: CoronaRapidAntigenTestParametersContainer @@ -11,8 +11,8 @@ interface CoronaTestConfig { } data class CoronaRapidAntigenTestParametersContainer( - val hoursToDeemTestOutdated: Duration = Duration.standardHours(DEFAULT_HOURS), - val durationToShowRiskCard: Duration = Duration.standardHours(DEFAULT_HOURS_SINCE_SAMPLE_COLLECTION), + val hoursToDeemTestOutdated: Duration = Duration.ofHours(DEFAULT_HOURS), + val durationToShowRiskCard: Duration = Duration.ofHours(DEFAULT_HOURS_SINCE_SAMPLE_COLLECTION), ) { companion object { const val DEFAULT_HOURS: Long = 48 @@ -21,7 +21,7 @@ data class CoronaRapidAntigenTestParametersContainer( } data class CoronaPCRTestParametersContainer( - val durationToShowRiskCard: Duration = Duration.standardHours(DEFAULT_HOURS_SINCE_TEST_REGISTRATION), + val durationToShowRiskCard: Duration = Duration.ofHours(DEFAULT_HOURS_SINCE_TEST_REGISTRATION), ) { companion object { const val DEFAULT_HOURS_SINCE_TEST_REGISTRATION = 168L // 7 days x 24 hours diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CovidCertificateConfig.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CovidCertificateConfig.kt index d6daccd20d7..7996390ddfb 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CovidCertificateConfig.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/CovidCertificateConfig.kt @@ -2,7 +2,7 @@ package de.rki.coronawarnapp.appconfig import de.rki.coronawarnapp.appconfig.mapping.ConfigMapper import okio.ByteString -import org.joda.time.Duration +import java.time.Duration interface CovidCertificateConfig { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ExposureDetectionConfig.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ExposureDetectionConfig.kt index a27962042d4..d0c9768a796 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ExposureDetectionConfig.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/ExposureDetectionConfig.kt @@ -2,7 +2,7 @@ package de.rki.coronawarnapp.appconfig import de.rki.coronawarnapp.appconfig.mapping.ConfigMapper import de.rki.coronawarnapp.server.protocols.internal.v2.ExposureDetectionParameters -import org.joda.time.Duration +import java.time.Duration interface ExposureDetectionConfig { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/KeyDownloadConfig.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/KeyDownloadConfig.kt index d61dd15258b..e5ebad758ce 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/KeyDownloadConfig.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/KeyDownloadConfig.kt @@ -2,9 +2,9 @@ package de.rki.coronawarnapp.appconfig import de.rki.coronawarnapp.appconfig.mapping.ConfigMapper import de.rki.coronawarnapp.diagnosiskeys.server.LocationCode -import org.joda.time.Duration -import org.joda.time.LocalDate -import org.joda.time.LocalTime +import java.time.Duration +import java.time.LocalDate +import java.time.LocalTime interface KeyDownloadConfig { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/devicetime/DeviceTimeHandler.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/devicetime/DeviceTimeHandler.kt index f71ab040d7f..dc9f907a248 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/devicetime/DeviceTimeHandler.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/devicetime/DeviceTimeHandler.kt @@ -29,7 +29,7 @@ class DeviceTimeHandler @Inject constructor( // ForegroundState.isInForeground has a day when opening the app. .sample(5000) .onEach { - Timber.tag(TAG).v("Current device time offset is: %dms", it.localOffset.millis) + Timber.tag(TAG).v("Current device time offset is: %dms", it.localOffset.toMillis()) if (it.isDeviceTimeCorrect) { Timber.v("Dismissing any notification, device time is correct again.") notification.dismiss() diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSource.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSource.kt index 7fa74084ffa..4fe8480bd19 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSource.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSource.kt @@ -8,8 +8,8 @@ import de.rki.coronawarnapp.appconfig.sources.local.LocalAppConfigSource import de.rki.coronawarnapp.appconfig.sources.remote.RemoteAppConfigSource import de.rki.coronawarnapp.main.CWASettings import de.rki.coronawarnapp.util.TimeStamper -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import timber.log.Timber import javax.inject.Inject @@ -26,7 +26,7 @@ class AppConfigSource @Inject constructor( Timber.tag(TAG).d("getConfigData(offlineMode=$offlineMode)") val localConfig = localAppConfigSource.getConfigData() - val nowUTC = timeStamper.nowUTC + val nowUTC = timeStamper.nowJavaUTC Timber.tag(TAG).d("nowUTC=%s localConfig.updatedAt=%s", nowUTC, localConfig?.updatedAt) if (localConfig != null && localConfig.isValid(nowUTC)) { @@ -48,7 +48,7 @@ class AppConfigSource @Inject constructor( if (!remoteConfig.isDeviceTimeCorrect) { Timber.tag(TAG).w( "Device time is incorrect, offset=%dmin", - remoteConfig.localOffset.standardMinutes + remoteConfig.localOffset.toMinutes() ) } if (remoteConfig.isDeviceTimeCorrect && cwaSettings.wasDeviceTimeIncorrectAcknowledged) { @@ -57,7 +57,7 @@ class AppConfigSource @Inject constructor( } if (remoteConfig.deviceTimeState == CORRECT && cwaSettings.firstReliableDeviceTime == Instant.EPOCH) { Timber.tag(TAG).i("Setting firstReliableDeviceTime to NOW (UTC). ") - cwaSettings.firstReliableDeviceTime = timeStamper.nowUTC + cwaSettings.firstReliableDeviceTime = timeStamper.nowJavaUTC } if (remoteConfig.deviceTimeState != cwaSettings.lastDeviceTimeStateChangeState) { Timber.tag(TAG).i( diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainer.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainer.kt index 03adfb0456b..1f50230cde0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainer.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainer.kt @@ -2,8 +2,8 @@ package de.rki.coronawarnapp.appconfig.internal import de.rki.coronawarnapp.appconfig.ConfigData import de.rki.coronawarnapp.appconfig.mapping.ConfigMapping -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant data class ConfigDataContainer( val serverTime: Instant, @@ -29,6 +29,6 @@ data class ConfigDataContainer( override fun isValid(nowUTC: Instant): Boolean = if (cacheValidity == Duration.ZERO) { false } else { - Duration(nowUTC, updatedAt).abs() <= cacheValidity + Duration.between(nowUTC, updatedAt).abs() <= cacheValidity } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/InternalConfigData.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/InternalConfigData.kt index 6eb41191dd0..fdcd69d1017 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/InternalConfigData.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/internal/InternalConfigData.kt @@ -1,8 +1,8 @@ package de.rki.coronawarnapp.appconfig.internal import com.google.gson.annotations.SerializedName -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant data class InternalConfigData( @SerializedName("rawData") val rawData: ByteArray, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestConfigMapper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestConfigMapper.kt index 4714f46d02e..cbda33b5864 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestConfigMapper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestConfigMapper.kt @@ -6,7 +6,7 @@ import de.rki.coronawarnapp.appconfig.CoronaRapidAntigenTestParametersContainer import de.rki.coronawarnapp.appconfig.CoronaTestConfig import de.rki.coronawarnapp.appconfig.CoronaTestConfigContainer import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid.ApplicationConfigurationAndroid -import org.joda.time.Duration +import java.time.Duration import timber.log.Timber import javax.inject.Inject @@ -28,10 +28,10 @@ class CoronaTestConfigMapper @Inject constructor() : CoronaTestConfig.Mapper { val coronaRapidAntigenTestParameters = if (coronaTestParameters.hasCoronaRapidAntigenTestParameters()) { val coronaRapidAntigenTestParameters = coronaTestParameters.coronaRapidAntigenTestParameters CoronaRapidAntigenTestParametersContainer( - hoursToDeemTestOutdated = Duration.standardHours( + hoursToDeemTestOutdated = Duration.ofHours( coronaRapidAntigenTestParameters.hoursToDeemTestOutdated.toLong() ), - durationToShowRiskCard = Duration.standardHours( + durationToShowRiskCard = Duration.ofHours( coronaRapidAntigenTestParameters.hoursSinceSampleCollectionToShowRiskCard.toLong() ) ) @@ -42,7 +42,7 @@ class CoronaTestConfigMapper @Inject constructor() : CoronaTestConfig.Mapper { val coronaPCRTestParameters = if (coronaTestParameters.hasCoronaPCRTestParameters()) { CoronaPCRTestParametersContainer( - durationToShowRiskCard = Duration.standardHours( + durationToShowRiskCard = Duration.ofHours( coronaTestParameters.coronaPCRTestParameters.hoursSinceTestRegistrationToShowRiskCard.toLong() ) ) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapper.kt index 78a6047e854..3446cf0a2c6 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapper.kt @@ -7,7 +7,7 @@ import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid import de.rki.coronawarnapp.server.protocols.internal.v2.DgcParameters import de.rki.coronawarnapp.util.toOkioByteString import okio.ByteString -import org.joda.time.Duration +import java.time.Duration import timber.log.Timber import javax.inject.Inject @@ -40,7 +40,7 @@ class CovidCertificateConfigMapper @Inject constructor() : CovidCertificateConfi Timber.e("Invalid value for waitAfterPublicKeyRegistration: %s", it) TestCertificateConfigContainer().waitAfterPublicKeyRegistration } else { - Duration.standardSeconds(it.toLong()) + Duration.ofSeconds(it.toLong()) } }, waitForRetry = waitForRetryInSeconds.let { @@ -48,7 +48,7 @@ class CovidCertificateConfigMapper @Inject constructor() : CovidCertificateConfi Timber.e("Invalid value for waitForRetryInSeconds: %s", it) TestCertificateConfigContainer().waitForRetry } else { - Duration.standardSeconds(it.toLong()) + Duration.ofSeconds(it.toLong()) } } ) @@ -60,7 +60,7 @@ class CovidCertificateConfigMapper @Inject constructor() : CovidCertificateConfi return DEFAULT_EXPIRATION_THRESHOLD } - return Duration.standardDays(expirationThresholdInDays.toLong()) + return Duration.ofDays(expirationThresholdInDays.toLong()) } private fun DgcParameters.DGCParameters.mapReissueServicePublicKeyDigest(): ByteString = try { @@ -78,11 +78,11 @@ class CovidCertificateConfigMapper @Inject constructor() : CovidCertificateConfi ) : CovidCertificateConfig data class TestCertificateConfigContainer( - override val waitAfterPublicKeyRegistration: Duration = Duration.standardSeconds(10), - override val waitForRetry: Duration = Duration.standardSeconds(10), + override val waitAfterPublicKeyRegistration: Duration = Duration.ofSeconds(10), + override val waitForRetry: Duration = Duration.ofSeconds(10), ) : CovidCertificateConfig.TestCertificate companion object { - private val DEFAULT_EXPIRATION_THRESHOLD: Duration get() = Duration.standardDays(14) + private val DEFAULT_EXPIRATION_THRESHOLD: Duration get() = Duration.ofDays(14) } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapper.kt index 900ce5bef4f..1bf71ca33d0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapper.kt @@ -5,7 +5,7 @@ import dagger.Reusable import de.rki.coronawarnapp.appconfig.ExposureDetectionConfig import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid import de.rki.coronawarnapp.server.protocols.internal.v2.ExposureDetectionParameters.ExposureDetectionParametersAndroid -import org.joda.time.Duration +import java.time.Duration import javax.inject.Inject @Reusable @@ -36,9 +36,9 @@ class ExposureDetectionConfigMapper @Inject constructor() : ExposureDetectionCon @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) fun ExposureDetectionParametersAndroid?.overAllDetectionTimeout(): Duration = if (this == null || overallTimeoutInSeconds > 3600 || overallTimeoutInSeconds <= 0) { - Duration.standardMinutes(15) + Duration.ofMinutes(15) } else { - Duration.standardSeconds(overallTimeoutInSeconds.toLong()) + Duration.ofSeconds(overallTimeoutInSeconds.toLong()) } // If we are outside the valid data range, fallback to default value. @@ -54,8 +54,8 @@ fun ExposureDetectionParametersAndroid?.maxExposureDetectionsPerDay(): Int = fun ExposureDetectionParametersAndroid?.minTimeBetweenExposureDetections(): Duration { val detectionsPerDay = this.maxExposureDetectionsPerDay() return if (detectionsPerDay == 0) { - Duration.standardDays(1) + Duration.ofDays(1) } else { - (24 / detectionsPerDay).let { Duration.standardHours(it.toLong()) } + (24 / detectionsPerDay).let { Duration.ofHours(it.toLong()) } } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/KeyDownloadParametersMapper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/KeyDownloadParametersMapper.kt index f9c95b41853..37760271f25 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/KeyDownloadParametersMapper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/KeyDownloadParametersMapper.kt @@ -6,10 +6,10 @@ import de.rki.coronawarnapp.appconfig.KeyDownloadConfig import de.rki.coronawarnapp.diagnosiskeys.server.LocationCode import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid import de.rki.coronawarnapp.server.protocols.internal.v2.KeyDownloadParameters.KeyDownloadParametersAndroid -import org.joda.time.Duration -import org.joda.time.LocalDate -import org.joda.time.LocalTime -import org.joda.time.format.DateTimeFormat +import java.time.Duration +import java.time.LocalDate +import java.time.LocalTime +import java.time.format.DateTimeFormatter import timber.log.Timber import javax.inject.Inject @@ -34,17 +34,17 @@ class KeyDownloadParametersMapper @Inject constructor() : KeyDownloadConfig.Mapp // If we are outside the valid data range, fallback to default value. private fun KeyDownloadParametersAndroid?.individualTimeout(): Duration = if (this == null || downloadTimeoutInSeconds > 1800 || downloadTimeoutInSeconds <= 0) { - Duration.standardSeconds(60) + Duration.ofSeconds(60) } else { - Duration.standardSeconds(downloadTimeoutInSeconds.toLong()) + Duration.ofSeconds(downloadTimeoutInSeconds.toLong()) } // If we are outside the valid data range, fallback to default value. private fun KeyDownloadParametersAndroid?.overAllTimeout(): Duration = if (this == null || overallTimeoutInSeconds > 1800 || overallTimeoutInSeconds <= 0) { - Duration.standardMinutes(8) + Duration.ofMinutes(8) } else { - Duration.standardSeconds(overallTimeoutInSeconds.toLong()) + Duration.ofSeconds(overallTimeoutInSeconds.toLong()) } private fun KeyDownloadParametersAndroid?.mapDayEtags(): List { @@ -106,8 +106,8 @@ class KeyDownloadParametersMapper @Inject constructor() : KeyDownloadConfig.Mapp ) : KeyDownloadConfig companion object { - private val DAY_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd") - private val HOUR_FORMATTER = DateTimeFormat.forPattern("H") + private val DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd") + private val HOUR_FORMATTER = DateTimeFormatter.ofPattern("H") } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSource.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSource.kt index 7000a6c71cb..27ced4bbe38 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSource.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/fallback/DefaultAppConfigSource.kt @@ -6,8 +6,8 @@ import de.rki.coronawarnapp.appconfig.ConfigData import de.rki.coronawarnapp.appconfig.internal.ConfigDataContainer import de.rki.coronawarnapp.appconfig.mapping.ConfigParser import de.rki.coronawarnapp.util.di.AppContext -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import javax.inject.Inject @Reusable diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorage.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorage.kt index 2a3677d7e1b..fe8334af4ba 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorage.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorage.kt @@ -10,12 +10,14 @@ import de.rki.coronawarnapp.util.di.AppContext import de.rki.coronawarnapp.util.serialization.BaseGson import de.rki.coronawarnapp.util.serialization.adapter.DurationAdapter import de.rki.coronawarnapp.util.serialization.adapter.InstantAdapter +import de.rki.coronawarnapp.util.serialization.adapter.JavaDurationAdapter +import de.rki.coronawarnapp.util.serialization.adapter.JavaInstantAdapter import de.rki.coronawarnapp.util.serialization.fromJson import de.rki.coronawarnapp.util.serialization.toJson import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import timber.log.Timber import java.io.File import javax.inject.Inject @@ -32,6 +34,8 @@ class AppConfigStorage @Inject constructor( baseGson.newBuilder() .registerTypeAdapter(Instant::class.java, InstantAdapter()) .registerTypeAdapter(Duration::class.java, DurationAdapter()) + .registerTypeAdapter(java.time.Instant::class.java, JavaInstantAdapter()) + .registerTypeAdapter(java.time.Duration::class.java, JavaDurationAdapter()) .create() } private val configDir = File(context.filesDir, "appconfig_storage") @@ -52,7 +56,7 @@ class AppConfigStorage @Inject constructor( serverTime = Instant.ofEpochMilli(legacyConfigFile.lastModified()), localOffset = Duration.ZERO, etag = "legacy.migration", - cacheValidity = Duration.standardSeconds(0) + cacheValidity = Duration.ofSeconds(0) ) } catch (e: Exception) { Timber.e(e, "Legacy config exits but couldn't be read.") diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServer.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServer.kt index df07ac03d4e..a3da7b0eab3 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServer.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServer.kt @@ -14,12 +14,12 @@ import de.rki.coronawarnapp.util.ZipHelper.unzip import de.rki.coronawarnapp.util.retrofit.etag import de.rki.coronawarnapp.util.security.SignatureValidation import okhttp3.CacheControl -import org.joda.time.Duration -import org.joda.time.Instant -import org.joda.time.format.DateTimeFormat import retrofit2.HttpException import retrofit2.Response import timber.log.Timber +import java.time.Duration +import java.time.Instant +import java.time.format.DateTimeFormatter import java.util.Locale import javax.inject.Inject @@ -60,7 +60,7 @@ class AppConfigServer @Inject constructor( exportBinary } - val localTime = timeStamper.nowUTC + val localTime = timeStamper.nowJavaUTC val headers = response.headers() @@ -73,9 +73,9 @@ class AppConfigServer @Inject constructor( Timber.tag(TAG).w("Test setting 'fakeCorrectDeviceTime' is active; time offset is now 0") Duration.ZERO } else { - Duration(serverTime, localTime) + Duration.between(serverTime, localTime) } - Timber.tag(TAG).v("Time offset was %dms", offset.millis) + Timber.tag(TAG).v("Time offset was %dms", offset.toMillis()) val cacheControl = CacheControl.parse(headers) @@ -83,9 +83,9 @@ class AppConfigServer @Inject constructor( if (it == 0) { // Server currently returns `Cache-Control max-age=0, no-cache, no-store` which breaks our caching Timber.tag(TAG).w("Server returned max-age=0: %s", cacheControl) - Duration.standardSeconds(300) + Duration.ofSeconds(300) } else { - Duration.standardSeconds(it.toLong()) + Duration.ofSeconds(it.toLong()) } } @@ -102,7 +102,7 @@ class AppConfigServer @Inject constructor( val rawDate = headers()["Date"] ?: throw IllegalArgumentException( "Server date unavailable: ${headers()}" ) - Instant.parse(rawDate, DATE_FORMAT) + DATE_FORMAT.parse(rawDate, Instant::from) } catch (e: Exception) { Timber.e("Failed to get server time.") null @@ -111,8 +111,8 @@ class AppConfigServer @Inject constructor( companion object { private const val EXPORT_BINARY_FILE_NAME = "export.bin" private const val EXPORT_SIGNATURE_FILE_NAME = "export.sig" - private val DATE_FORMAT = DateTimeFormat - .forPattern("EEE, dd MMM yyyy HH:mm:ss zzz") + private val DATE_FORMAT = DateTimeFormatter + .ofPattern("EEE, dd MMM yyyy HH:mm:ss zzz") .withLocale(Locale.ROOT) private val TAG = AppConfigServer::class.java.simpleName } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RACoronaTest.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RACoronaTest.kt index 48f8720e829..a0bf4b98b92 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RACoronaTest.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RACoronaTest.kt @@ -14,6 +14,7 @@ import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest import de.rki.coronawarnapp.coronatest.type.PersonalCoronaTest import de.rki.coronawarnapp.coronatest.type.RegistrationToken import de.rki.coronawarnapp.coronatest.type.TestIdentifier +import de.rki.coronawarnapp.util.toJavaInstant import org.joda.time.Instant import org.joda.time.LocalDate @@ -92,12 +93,12 @@ data class RACoronaTest( override val type: BaseCoronaTest.Type get() = BaseCoronaTest.Type.RAPID_ANTIGEN - private fun isOutdated(nowUTC: Instant, testConfig: CoronaTestConfig): Boolean = - testTakenAt.plus(testConfig.ratParameters.hoursToDeemTestOutdated).isBefore(nowUTC) + private fun isOutdated(nowUTC: java.time.Instant, testConfig: CoronaTestConfig): Boolean = + testTakenAt.toJavaInstant().plus(testConfig.ratParameters.hoursToDeemTestOutdated).isBefore(nowUTC) fun getState(nowUTC: Instant, testConfig: CoronaTestConfig) = when { isRecycled -> State.RECYCLED - testResult == RAT_NEGATIVE && isOutdated(nowUTC, testConfig) -> State.OUTDATED + testResult == RAT_NEGATIVE && isOutdated(nowUTC.toJavaInstant(), testConfig) -> State.OUTDATED else -> when (testResult) { PCR_OR_RAT_PENDING, RAT_PENDING -> State.PENDING diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateChecker.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateChecker.kt index 99581380f5f..513dd0412e8 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateChecker.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateChecker.kt @@ -12,6 +12,7 @@ import de.rki.coronawarnapp.covidcertificate.revocation.check.DccRevocationCheck import de.rki.coronawarnapp.covidcertificate.signature.core.DscSignatureValidator import de.rki.coronawarnapp.tag import de.rki.coronawarnapp.util.TimeStamper +import de.rki.coronawarnapp.util.toJoda import kotlinx.coroutines.flow.first import timber.log.Timber import javax.inject.Inject @@ -35,7 +36,7 @@ class DccStateChecker @Inject constructor( else -> try { val threshold = appConfigProvider.currentConfig.first().covidCertificateParameters.expirationThreshold dscSignatureValidator.validateSignature(dccData, dccValidityMeasures.dscSignatureList) // throws if invalid - dccExpirationChecker.getExpirationState(dccData, threshold, timeStamper.nowUTC) + dccExpirationChecker.getExpirationState(dccData, threshold.toJoda(), timeStamper.nowUTC) } catch (e: Exception) { Timber.tag(TAG).w("Certificate had invalid signature %s", e.message) Invalid() diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessor.kt index dfaf18815a7..40c12efb4a6 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessor.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessor.kt @@ -17,10 +17,11 @@ import de.rki.coronawarnapp.covidcertificate.test.core.storage.types.RetrievedTe import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.encryption.rsa.RSACryptography import de.rki.coronawarnapp.util.encryption.rsa.RSAKeyPairGenerator +import de.rki.coronawarnapp.util.toJavaInstant import kotlinx.coroutines.delay import kotlinx.coroutines.flow.first import okio.ByteString.Companion.decodeBase64 -import org.joda.time.Duration +import java.time.Duration import timber.log.Timber import javax.inject.Inject @@ -159,14 +160,16 @@ class TestCertificateProcessor @Inject constructor( val certConfig = appConfigProvider.currentConfig.first().covidCertificateParameters.testCertificate - val nowUTC = timeStamper.nowUTC - val certAvailableAt = data.publicKeyRegisteredAt!!.plus(certConfig.waitAfterPublicKeyRegistration) - val certAvailableIn = Duration(nowUTC, certAvailableAt) + val nowUTC = timeStamper.nowJavaUTC + val certAvailableAt = data.publicKeyRegisteredAt + ?.toJavaInstant() + ?.plus(certConfig.waitAfterPublicKeyRegistration) + val certAvailableIn = Duration.between(nowUTC, certAvailableAt) if (certAvailableIn > Duration.ZERO && certAvailableIn <= certConfig.waitAfterPublicKeyRegistration) { Timber.tag(TAG) - .d("Delaying certificate retrieval by %d ms", certAvailableIn.millis) - delay(certAvailableIn.millis) + .d("Delaying certificate retrieval by %d ms", certAvailableIn.toMillis()) + delay(certAvailableIn.toMillis()) } val executeRequest: suspend () -> TestCertificateComponents = { @@ -177,7 +180,7 @@ class TestCertificateProcessor @Inject constructor( executeRequest() } catch (e: TestCertificateException) { if (e.errorCode == ErrorCode.DCC_COMP_202) { - delay(certConfig.waitForRetry.millis) + delay(certConfig.waitForRetry.toMillis()) executeRequest() } else { throw e diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNet.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNet.kt index 88f8fdfdec8..9cd0c5da2a2 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNet.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNet.kt @@ -13,7 +13,6 @@ import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.di.AppContext import de.rki.coronawarnapp.util.gplay.GoogleApiVersion import de.rki.coronawarnapp.util.security.RandomStrong -import de.rki.coronawarnapp.util.toJavaInstant import okio.ByteString import okio.ByteString.Companion.decodeHex import okio.ByteString.Companion.toByteString @@ -113,7 +112,7 @@ class CWASafetyNet @Inject constructor( val skip24hCheck = CWADebug.isDeviceForTestersBuild && testSettings.skipSafetyNetTimeCheck.value val nowUTC = timeStamper.nowJavaUTC - val firstReliableTimeStamp = cwaSettings.firstReliableDeviceTime.toJavaInstant() + val firstReliableTimeStamp = cwaSettings.firstReliableDeviceTime val timeSinceOnboarding = Duration.between(firstReliableTimeStamp, nowUTC) Timber.d("firstReliableTimeStamp=%s, now=%s", firstReliableTimeStamp, nowUTC) Timber.d("skip24hCheck=%b, timeSinceOnboarding=%dh", skip24hCheck, timeSinceOnboarding.toHours()) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTask.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTask.kt index 31bc86a747d..05bfe1cfd32 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTask.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTask.kt @@ -15,6 +15,7 @@ import de.rki.coronawarnapp.task.TaskCancellationException import de.rki.coronawarnapp.task.TaskFactory import de.rki.coronawarnapp.task.TaskFactory.Config.CollisionBehavior import de.rki.coronawarnapp.util.TimeStamper +import de.rki.coronawarnapp.util.toJoda import de.rki.coronawarnapp.util.ui.toLazyString import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -152,7 +153,7 @@ class DownloadDiagnosisKeysTask @Inject constructor( return false } - val nextDetectionAt = lastDetection.startedAt.plus(exposureConfig.minTimeBetweenDetections) + val nextDetectionAt = lastDetection.startedAt.plus(exposureConfig.minTimeBetweenDetections.toJoda()) Duration(now, nextDetectionAt).also { Timber.tag(TAG).d("Next detection is available in %d min", it.standardMinutes) @@ -240,7 +241,7 @@ class DownloadDiagnosisKeysTask @Inject constructor( ) : TaskFactory { override suspend fun createConfig(): TaskFactory.Config = Config( - executionTimeout = appConfigProvider.getAppConfig().overallDownloadTimeout + executionTimeout = appConfigProvider.getAppConfig().overallDownloadTimeout.toJoda() ) override val taskProvider: () -> Task = { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadTool.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadTool.kt index f0a2392146c..3778620f642 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadTool.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadTool.kt @@ -21,7 +21,7 @@ class KeyDownloadTool @Inject constructor( val saveTo = cachedKey.path val keyInfo = cachedKey.info - val downloadInfo = withTimeout(downloadConfig.individualDownloadTimeout.millis) { + val downloadInfo = withTimeout(downloadConfig.individualDownloadTimeout.toMillis()) { keyServer.downloadKeyFile( locationCode = keyInfo.location, day = keyInfo.day, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/model/CoronaTest.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/model/CoronaTest.kt index 7db730822dd..1d2a9364478 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/model/CoronaTest.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/model/CoronaTest.kt @@ -10,6 +10,7 @@ import de.rki.coronawarnapp.coronatest.type.RegistrationToken import de.rki.coronawarnapp.coronatest.type.TestIdentifier import de.rki.coronawarnapp.util.TimeAndDateExtensions.toShortDayFormat import de.rki.coronawarnapp.util.TimeAndDateExtensions.toUserTimeZone +import de.rki.coronawarnapp.util.toJavaInstant import org.joda.time.Instant import org.joda.time.LocalDate @@ -67,10 +68,10 @@ data class CoronaTest( val testTakenAt: Instant get() = (additionalInfo?.sampleCollectedAt ?: additionalInfo?.createdAt) as Instant - private fun isOutdated(nowUTC: Instant, testConfig: CoronaTestConfig): Boolean = - testTakenAt.plus(testConfig.ratParameters.hoursToDeemTestOutdated).isBefore(nowUTC) + private fun isOutdated(nowUTC: java.time.Instant, testConfig: CoronaTestConfig): Boolean = + testTakenAt.toJavaInstant().plus(testConfig.ratParameters.hoursToDeemTestOutdated).isBefore(nowUTC) - fun getUiState(nowUTC: Instant, testConfig: CoronaTestConfig) = when { + fun getUiState(nowUTC: java.time.Instant, testConfig: CoronaTestConfig) = when { isRecycled -> State.RECYCLED testResult == CoronaTestResult.RAT_NEGATIVE && isOutdated(nowUTC, testConfig) -> State.OUTDATED else -> when (testResult) { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt index 121905758e5..e29ff868d65 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt @@ -111,7 +111,7 @@ class FamilyTestListViewModel @AssistedInject constructor( }.asLiveData(context = dispatcherProvider.Default) private fun FamilyCoronaTest.toPCRTestCardItem(coronaTestConfig: CoronaTestConfig): FamilyTestListItem = - when (this.coronaTest.getUiState(timeStamper.nowUTC, coronaTestConfig)) { + when (this.coronaTest.getUiState(timeStamper.nowJavaUTC, coronaTestConfig)) { State.PENDING, State.NEGATIVE, State.POSITIVE, @@ -141,7 +141,7 @@ class FamilyTestListViewModel @AssistedInject constructor( } private fun FamilyCoronaTest.toRapidTestCardItem(coronaTestConfig: CoronaTestConfig): FamilyTestListItem = - when (this.coronaTest.getUiState(timeStamper.nowUTC, coronaTestConfig)) { + when (this.coronaTest.getUiState(timeStamper.nowJavaUTC, coronaTestConfig)) { State.PENDING, State.NEGATIVE, State.POSITIVE, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/main/CWASettings.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/main/CWASettings.kt index 7b60a94ad44..9d752b16840 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/main/CWASettings.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/main/CWASettings.kt @@ -40,9 +40,9 @@ class CWASettings @Inject constructor( get() = prefs.getBoolean(PKEY_CERT_GROUPING_MIGRATION, false) set(value) = prefs.edit { putBoolean(PKEY_CERT_GROUPING_MIGRATION, value) } - var firstReliableDeviceTime: Instant - get() = Instant.ofEpochMilli(prefs.getLong(PKEY_DEVICE_TIME_FIRST_RELIABLE, 0L)) - set(value) = prefs.edit { putLong(PKEY_DEVICE_TIME_FIRST_RELIABLE, value.millis) } + var firstReliableDeviceTime: java.time.Instant + get() = java.time.Instant.ofEpochMilli(prefs.getLong(PKEY_DEVICE_TIME_FIRST_RELIABLE, 0L)) + set(value) = prefs.edit { putLong(PKEY_DEVICE_TIME_FIRST_RELIABLE, value.toEpochMilli()) } var lastDeviceTimeStateChangeAt: Instant get() = Instant.ofEpochMilli(prefs.getLong(PKEY_DEVICE_TIME_LAST_STATE_CHANGE_TIME, 0L)) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTracker.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTracker.kt index 21a2e33295e..f9f9e33f185 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTracker.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTracker.kt @@ -7,6 +7,7 @@ import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.coroutine.DispatcherProvider import de.rki.coronawarnapp.util.flow.HotDataFlow import de.rki.coronawarnapp.util.mutate +import de.rki.coronawarnapp.util.toJavaInstant import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow @@ -48,12 +49,12 @@ class DefaultExposureDetectionTracker @Inject constructor( flow { while (true) { hd.updateBlocking { - val timeNow = timeStamper.nowUTC + val timeNow = timeStamper.nowJavaUTC Timber.v("Running timeout check (now=%s): %s", timeNow, values) val timeoutLimit = appConfigProvider.currentConfig.first().overallDetectionTimeout mutate { values.filter { it.isCalculating }.toList().forEach { - if (timeNow.isAfter(it.startedAt.plus(timeoutLimit))) { + if (timeNow.isAfter(it.startedAt.toJavaInstant().plus(timeoutLimit))) { Timber.w("Calculation timeout on %s", it) this[it.identifier] = it.copy( finishedAt = timeStamper.nowUTC, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingWarningTask.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingWarningTask.kt index b599f3eaf8c..afc682995b2 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingWarningTask.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingWarningTask.kt @@ -16,6 +16,7 @@ import de.rki.coronawarnapp.presencetracing.warning.storage.TraceWarningReposito import de.rki.coronawarnapp.task.Task import de.rki.coronawarnapp.task.TaskCancellationException import de.rki.coronawarnapp.task.TaskFactory +import de.rki.coronawarnapp.util.toJoda import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.firstOrNull @@ -173,7 +174,7 @@ class PresenceTracingWarningTask @Inject constructor( ) : TaskFactory { override suspend fun createConfig(): TaskFactory.Config = Config( - executionTimeout = appConfigProvider.getAppConfig().overallDownloadTimeout + executionTimeout = appConfigProvider.getAppConfig().overallDownloadTimeout.toJoda() ) override val taskProvider: () -> Task = { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageDownloader.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageDownloader.kt index ae70ae71002..cba5a143272 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageDownloader.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageDownloader.kt @@ -41,14 +41,14 @@ class TraceWarningPackageDownloader @Inject constructor( mode: TraceWarningApi.Mode, location: LocationCode, hourIntervals: List, - downloadTimeout: Duration + downloadTimeout: java.time.Duration ): DownloadResult { Timber.tag(TAG).d("Launching %d downloads ($location): %s", hourIntervals.size, hourIntervals) val launcher: CoroutineScope.(HourInterval) -> Deferred = { hourInterval -> async { val metadata = repository.createMetadata(location, hourInterval) - withTimeout(downloadTimeout.millis) { + withTimeout(downloadTimeout.toMillis()) { downloadPackageForMetaData(mode, metadata) } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/EwRiskLevelTask.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/EwRiskLevelTask.kt index 8e2c6718bf7..b5e277ff6ce 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/EwRiskLevelTask.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/EwRiskLevelTask.kt @@ -26,6 +26,7 @@ import de.rki.coronawarnapp.task.common.Finished import de.rki.coronawarnapp.task.common.Started import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.device.BackgroundModeStatus +import de.rki.coronawarnapp.util.toJoda import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.first @@ -86,7 +87,7 @@ class EwRiskLevelTask @Inject constructor( if (!configData.isDeviceTimeCorrect) { Timber.w("Device time is incorrect, offset: %s", configData.localOffset) - val currentServerTime = nowUtc.minus(configData.localOffset) + val currentServerTime = nowUtc.minus(configData.localOffset.toJoda()) Timber.d("Calculated current server time: %s", currentServerTime) return EwRiskLevelTaskResult( calculatedAt = currentServerTime, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfo.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfo.kt index a627e073272..b45eee9837d 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfo.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfo.kt @@ -8,6 +8,7 @@ import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest import de.rki.coronawarnapp.coronatest.type.pcr.PCRCoronaTest import de.rki.coronawarnapp.coronatest.type.rapidantigen.RACoronaTest import de.rki.coronawarnapp.util.TimeStamper +import de.rki.coronawarnapp.util.toJavaInstant import kotlinx.coroutines.flow.first import org.joda.time.Duration import javax.inject.Inject @@ -39,10 +40,10 @@ class RiskCardDisplayInfo @Inject constructor( val coronaTestConfig = appConfigProvider.currentConfig.first().coronaTestParameters val (testTimestamp, thresholdDuration) = when (this) { - is PCRCoronaTest -> registeredAt to coronaTestConfig.pcrParameters.durationToShowRiskCard - is RACoronaTest -> testTakenAt to coronaTestConfig.ratParameters.durationToShowRiskCard + is PCRCoronaTest -> registeredAt.toJavaInstant() to coronaTestConfig.pcrParameters.durationToShowRiskCard + is RACoronaTest -> testTakenAt.toJavaInstant() to coronaTestConfig.ratParameters.durationToShowRiskCard else -> error("Unsupported test type=$type") } - return Duration(testTimestamp, timeStamper.nowUTC) >= thresholdDuration + return java.time.Duration.between(testTimestamp, timeStamper.nowJavaUTC) >= thresholdDuration } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/JodaMigration.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/JodaMigration.kt index 25ac6d96448..db9509dfb92 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/JodaMigration.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/JodaMigration.kt @@ -2,3 +2,4 @@ package de.rki.coronawarnapp.util fun org.joda.time.LocalDate.toJavaTime(): java.time.LocalDate = java.time.LocalDate.of(year, monthOfYear, dayOfMonth) fun org.joda.time.Instant.toJavaInstant(): java.time.Instant = java.time.Instant.ofEpochMilli(millis) +fun java.time.Duration.toJoda(): org.joda.time.Duration = org.joda.time.Duration(toMillis()) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/serialization/adapter/JavaDurationAdapter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/serialization/adapter/JavaDurationAdapter.kt new file mode 100644 index 00000000000..a6d7c99f5cd --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/serialization/adapter/JavaDurationAdapter.kt @@ -0,0 +1,27 @@ +package de.rki.coronawarnapp.util.serialization.adapter + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonToken +import com.google.gson.stream.JsonWriter +import java.time.Duration + +class JavaDurationAdapter : TypeAdapter() { + override fun write(out: JsonWriter, value: Duration?) { + if (value == null) { + out.nullValue() + } else { + out.value(value.toMillis()) + } + } + + override fun read(reader: JsonReader): Duration? = when (reader.peek()) { + JsonToken.NULL -> { + reader.nextNull() + null + } + else -> { + Duration.ofMillis(reader.nextLong()) + } + } +} diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/AppConfigProviderTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/AppConfigProviderTest.kt index ee6236f1f22..ee9445af872 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/AppConfigProviderTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/AppConfigProviderTest.kt @@ -14,8 +14,8 @@ import io.mockk.impl.annotations.MockK import io.mockk.just import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.advanceUntilIdle -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -47,12 +47,12 @@ class AppConfigProviderTest : BaseIOTest() { mappedConfig = configData, identifier = "identifier", configType = ConfigData.Type.FROM_SERVER, - cacheValidity = Duration.standardMinutes(5) + cacheValidity = Duration.ofMinutes(5) ) coEvery { appConfigSource.clear() } just Runs coEvery { appConfigSource.getConfigData(any()) } returns testConfigDownload - every { timeStamper.nowUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") + every { timeStamper.nowJavaUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") } @AfterEach @@ -76,7 +76,7 @@ class AppConfigProviderTest : BaseIOTest() { mappedConfig = configData, identifier = "${++counter}", configType = ConfigData.Type.FROM_SERVER, - cacheValidity = Duration.standardMinutes(5) + cacheValidity = Duration.ofMinutes(5) ) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSourceTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSourceTest.kt index 477602e285e..2ca1e480681 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSourceTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/AppConfigSourceTest.kt @@ -20,8 +20,8 @@ import io.mockk.just import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.test.runTest -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -36,29 +36,29 @@ class AppConfigSourceTest : BaseTest() { private val remoteConfig = ConfigDataContainer( serverTime = Instant.EPOCH, - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), mappedConfig = mockk().apply { every { isDeviceTimeCheckEnabled } returns true }, configType = ConfigData.Type.FROM_SERVER, identifier = "remoteetag", - cacheValidity = Duration.standardSeconds(42) + cacheValidity = Duration.ofSeconds(42) ) private val localConfig = ConfigDataContainer( serverTime = Instant.EPOCH, - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), mappedConfig = mockk().apply { every { isDeviceTimeCheckEnabled } returns true }, configType = ConfigData.Type.LAST_RETRIEVED, identifier = "localetag", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) private val defaultConfig = ConfigDataContainer( serverTime = Instant.EPOCH, - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), mappedConfig = mockk().apply { every { isDeviceTimeCheckEnabled } returns true }, @@ -81,7 +81,8 @@ class AppConfigSourceTest : BaseTest() { } coEvery { defaultSource.getConfigData() } returns defaultConfig - every { timeStamper.nowUTC } returns Instant.EPOCH.plus(Duration.standardHours(1)) + every { timeStamper.nowUTC } returns org.joda.time.Instant.EPOCH.plus(org.joda.time.Duration.standardHours(1)) + every { timeStamper.nowJavaUTC } returns Instant.EPOCH.plus(Duration.ofHours(1)) every { cwaSettings.wasDeviceTimeIncorrectAcknowledged } returns false every { cwaSettings.wasDeviceTimeIncorrectAcknowledged = any() } just Runs @@ -89,7 +90,7 @@ class AppConfigSourceTest : BaseTest() { every { cwaSettings.firstReliableDeviceTime } returns Instant.EPOCH every { cwaSettings.firstReliableDeviceTime = any() } just Runs - every { cwaSettings.lastDeviceTimeStateChangeAt } returns Instant.EPOCH + every { cwaSettings.lastDeviceTimeStateChangeAt } returns org.joda.time.Instant.EPOCH every { cwaSettings.lastDeviceTimeStateChangeAt = any() } just Runs every { cwaSettings.lastDeviceTimeStateChangeState } returns ConfigData.DeviceTimeState.INCORRECT every { cwaSettings.lastDeviceTimeStateChangeState = any() } just Runs @@ -110,29 +111,33 @@ class AppConfigSourceTest : BaseTest() { coVerifySequence { localSource.getConfigData() - timeStamper.nowUTC + timeStamper.nowJavaUTC } } @Test fun `remote config is used if local config is not valid`() = runTest { - every { timeStamper.nowUTC } returns Instant.EPOCH - .plus(Duration.standardHours(1)) - .plus(Duration.standardSeconds(301)) // Local config has 300 seconds validity + every { timeStamper.nowJavaUTC } returns Instant.EPOCH + .plus(Duration.ofHours(1)) + .plus(Duration.ofSeconds(301)) // Local config has 300 seconds validity + + every { timeStamper.nowUTC } returns org.joda.time.Instant.EPOCH + .plus(org.joda.time.Duration.standardHours(1)) + .plus(org.joda.time.Duration.standardSeconds(301)) val instance = createInstance() instance.getConfigData() shouldBe remoteConfig coVerifyOrder { localSource.getConfigData() - timeStamper.nowUTC + timeStamper.nowJavaUTC remoteSource.getConfigData() } } @Test fun `local config is used despite being invalid if remote config is unavailable`() = runTest { - every { timeStamper.nowUTC } returns Instant.EPOCH.plus(Duration.standardHours(2)) + every { timeStamper.nowJavaUTC } returns Instant.EPOCH.plus(Duration.ofHours(2)) coEvery { remoteSource.getConfigData() } returns null val instance = createInstance() @@ -143,7 +148,7 @@ class AppConfigSourceTest : BaseTest() { coVerifySequence { localSource.getConfigData() - timeStamper.nowUTC + timeStamper.nowJavaUTC remoteSource.getConfigData() } } @@ -183,7 +188,7 @@ class AppConfigSourceTest : BaseTest() { coEvery { localSource.getConfigData() } returns null coEvery { remoteSource.getConfigData() } returns remoteConfig.copy( - localOffset = Duration.standardHours(3) + localOffset = Duration.ofHours(3) ) createInstance().getConfigData() @@ -201,7 +206,7 @@ class AppConfigSourceTest : BaseTest() { createInstance().getConfigData() verify { - cwaSettings.firstReliableDeviceTime = Instant.EPOCH.plus(Duration.standardHours(1)) + cwaSettings.firstReliableDeviceTime = Instant.EPOCH.plus(Duration.ofHours(1)) } } @@ -219,7 +224,7 @@ class AppConfigSourceTest : BaseTest() { @Test fun `first reliable device time is not set, if the device time is incorrect`() = runTest { - coEvery { remoteSource.getConfigData() } returns remoteConfig.copy(localOffset = Duration.standardDays(1)) + coEvery { remoteSource.getConfigData() } returns remoteConfig.copy(localOffset = Duration.ofDays(1)) coEvery { localSource.getConfigData() } returns null createInstance().getConfigData() @@ -233,7 +238,7 @@ class AppConfigSourceTest : BaseTest() { fun `if the device time state changes we save the timestamp and the current state`() = runTest { coEvery { localSource.getConfigData() } returns null // INCORRECT - coEvery { remoteSource.getConfigData() } returns remoteConfig.copy(localOffset = Duration.standardDays(1)) + coEvery { remoteSource.getConfigData() } returns remoteConfig.copy(localOffset = Duration.ofDays(1)) createInstance().getConfigData() @@ -247,7 +252,8 @@ class AppConfigSourceTest : BaseTest() { createInstance().getConfigData() verify { - cwaSettings.lastDeviceTimeStateChangeAt = Instant.EPOCH.plus(Duration.standardHours(1)) + cwaSettings.lastDeviceTimeStateChangeAt = + org.joda.time.Instant.EPOCH.plus(org.joda.time.Duration.standardHours(1)) cwaSettings.lastDeviceTimeStateChangeState = ConfigData.DeviceTimeState.CORRECT } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainerTest.kt index fcceb3275b1..edc65dbf285 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/internal/ConfigDataContainerTest.kt @@ -5,8 +5,8 @@ import de.rki.coronawarnapp.appconfig.mapping.ConfigMapping import io.kotest.matchers.shouldBe import io.mockk.every import io.mockk.mockk -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -17,96 +17,96 @@ class ConfigDataContainerTest : BaseTest() { val now = Instant.EPOCH val config = ConfigDataContainer( serverTime = now, - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), mappedConfig = mockk(), configType = ConfigData.Type.LAST_RETRIEVED, identifier = "localetag", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) // isValid uses the "updatedTimestamp" with updatedAt = serverTime + serverOffset = ourTime // Without the offset, we would already be off by one our config.isValid(now) shouldBe false - config.isValid(now.plus(Duration.standardSeconds(300))) shouldBe false - config.isValid(now.minus(Duration.standardSeconds(300))) shouldBe false - config.isValid(now.plus(Duration.standardSeconds(1))) shouldBe false - config.isValid(now.minus(Duration.standardSeconds(1))) shouldBe false + config.isValid(now.plus(Duration.ofSeconds(300))) shouldBe false + config.isValid(now.minus(Duration.ofSeconds(300))) shouldBe false + config.isValid(now.plus(Duration.ofSeconds(1))) shouldBe false + config.isValid(now.minus(Duration.ofSeconds(1))) shouldBe false val nowWithOffset = now.plus(config.localOffset) config.isValid(nowWithOffset) shouldBe true - config.isValid(nowWithOffset.plus(Duration.standardSeconds(1))) shouldBe true - config.isValid(nowWithOffset.minus(Duration.standardSeconds(1))) shouldBe true + config.isValid(nowWithOffset.plus(Duration.ofSeconds(1))) shouldBe true + config.isValid(nowWithOffset.minus(Duration.ofSeconds(1))) shouldBe true - config.isValid(nowWithOffset.plus(Duration.standardSeconds(299))) shouldBe true - config.isValid(nowWithOffset.minus(Duration.standardSeconds(299))) shouldBe true + config.isValid(nowWithOffset.plus(Duration.ofSeconds(299))) shouldBe true + config.isValid(nowWithOffset.minus(Duration.ofSeconds(299))) shouldBe true - config.isValid(nowWithOffset.minus(Duration.standardSeconds(300))) shouldBe true - config.isValid(nowWithOffset.plus(Duration.standardSeconds(300))) shouldBe true + config.isValid(nowWithOffset.minus(Duration.ofSeconds(300))) shouldBe true + config.isValid(nowWithOffset.plus(Duration.ofSeconds(300))) shouldBe true - config.isValid(nowWithOffset.minus(Duration.standardSeconds(301))) shouldBe false - config.isValid(nowWithOffset.plus(Duration.standardSeconds(301))) shouldBe false + config.isValid(nowWithOffset.minus(Duration.ofSeconds(301))) shouldBe false + config.isValid(nowWithOffset.plus(Duration.ofSeconds(301))) shouldBe false } @Test fun `cache validity can be set to 0`() { val config = ConfigDataContainer( serverTime = Instant.EPOCH, - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), mappedConfig = mockk(), configType = ConfigData.Type.LAST_RETRIEVED, identifier = "localetag", - cacheValidity = Duration.standardSeconds(0) + cacheValidity = Duration.ofSeconds(0) ) config.isValid(Instant.EPOCH) shouldBe false - config.isValid(Instant.EPOCH.plus(Duration.standardHours(1))) shouldBe false - config.isValid(Instant.EPOCH.plus(Duration.standardHours(24))) shouldBe false - config.isValid(Instant.EPOCH.plus(Duration.standardDays(14))) shouldBe false + config.isValid(Instant.EPOCH.plus(Duration.ofHours(1))) shouldBe false + config.isValid(Instant.EPOCH.plus(Duration.ofHours(24))) shouldBe false + config.isValid(Instant.EPOCH.plus(Duration.ofDays(14))) shouldBe false - config.isValid(Instant.EPOCH.minus(Duration.standardHours(1))) shouldBe false - config.isValid(Instant.EPOCH.minus(Duration.standardHours(24))) shouldBe false - config.isValid(Instant.EPOCH.minus(Duration.standardDays(14))) shouldBe false + config.isValid(Instant.EPOCH.minus(Duration.ofHours(1))) shouldBe false + config.isValid(Instant.EPOCH.minus(Duration.ofHours(24))) shouldBe false + config.isValid(Instant.EPOCH.minus(Duration.ofDays(14))) shouldBe false } @Test fun `updated at is based on servertime and offset`() { val config = ConfigDataContainer( serverTime = Instant.EPOCH, - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), mappedConfig = mockk(), configType = ConfigData.Type.LAST_RETRIEVED, identifier = "localetag", - cacheValidity = Duration.standardSeconds(0) + cacheValidity = Duration.ofSeconds(0) ) - config.updatedAt shouldBe Instant.EPOCH.plus(Duration.standardHours(1)) + config.updatedAt shouldBe Instant.EPOCH.plus(Duration.ofHours(1)) } @Test fun `device time correctness is checked via localOffset`() { val forOffset: (Duration) -> ConfigData = { ConfigDataContainer( - serverTime = Instant.EPOCH.plus(Duration.standardDays(1)), + serverTime = Instant.EPOCH.plus(Duration.ofDays(1)), localOffset = it, mappedConfig = mockk().apply { every { isDeviceTimeCheckEnabled } returns true }, configType = ConfigData.Type.LAST_RETRIEVED, identifier = "localetag", - cacheValidity = Duration.standardSeconds(0) + cacheValidity = Duration.ofSeconds(0) ) } - forOffset(Duration.standardHours(1)).isDeviceTimeCorrect shouldBe true + forOffset(Duration.ofHours(1)).isDeviceTimeCorrect shouldBe true forOffset(Duration.ZERO).isDeviceTimeCorrect shouldBe true - forOffset(Duration.standardHours(2).minus(1)).isDeviceTimeCorrect shouldBe true - forOffset(Duration.standardHours(-2).plus(1)).isDeviceTimeCorrect shouldBe true + forOffset(Duration.ofHours(2).minusMillis(1)).isDeviceTimeCorrect shouldBe true + forOffset(Duration.ofHours(-2).plusMillis(1)).isDeviceTimeCorrect shouldBe true - forOffset(Duration.standardHours(2)).isDeviceTimeCorrect shouldBe false - forOffset(Duration.standardHours(-2)).isDeviceTimeCorrect shouldBe false + forOffset(Duration.ofHours(2)).isDeviceTimeCorrect shouldBe false + forOffset(Duration.ofHours(-2)).isDeviceTimeCorrect shouldBe false - forOffset(Duration.standardHours(2).plus(1)).isDeviceTimeCorrect shouldBe false - forOffset(Duration.standardHours(-2).minus(1)).isDeviceTimeCorrect shouldBe false + forOffset(Duration.ofHours(2).plusMillis(1)).isDeviceTimeCorrect shouldBe false + forOffset(Duration.ofHours(-2).minusMillis(1)).isDeviceTimeCorrect shouldBe false } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestParametersDistinctTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestParametersDistinctTest.kt index 401c958d19d..062d1cec9b3 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestParametersDistinctTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CoronaTestParametersDistinctTest.kt @@ -7,19 +7,19 @@ import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flow import kotlinx.coroutines.test.runTest -import org.joda.time.Duration +import java.time.Duration import org.junit.Test import testhelpers.BaseTest class CoronaTestParametersDistinctTest : BaseTest() { - private val durationOf48H: Duration = Duration.standardHours(48) - private val durationOf12H: Duration = Duration.standardHours(12) + private val durationOf48H: Duration = Duration.ofHours(48) + private val durationOf12H: Duration = Duration.ofHours(12) @Test fun `can we use distinctUntilChanged on CoronaTestParameters`() = runTest { val flow = flow { emit(CoronaRapidAntigenTestParametersContainer(durationOf48H)) - emit(CoronaRapidAntigenTestParametersContainer(Duration.standardHours(48))) + emit(CoronaRapidAntigenTestParametersContainer(Duration.ofHours(48))) emit(CoronaRapidAntigenTestParametersContainer(durationOf12H)) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapperTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapperTest.kt index 9e78c074856..b07f2870279 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapperTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/CovidCertificateConfigMapperTest.kt @@ -10,7 +10,7 @@ import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.types.beInstanceOf import okio.ByteString.Companion.toByteString -import org.joda.time.Duration +import java.time.Duration import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -54,9 +54,9 @@ class CovidCertificateConfigMapperTest : BaseTest() { ) .build() createInstance().map(config).apply { - testCertificate.waitAfterPublicKeyRegistration shouldBe Duration.standardSeconds(60) - testCertificate.waitForRetry shouldBe Duration.standardSeconds(60) - expirationThreshold shouldBe Duration.standardDays(13) + testCertificate.waitAfterPublicKeyRegistration shouldBe Duration.ofSeconds(60) + testCertificate.waitForRetry shouldBe Duration.ofSeconds(60) + expirationThreshold shouldBe Duration.ofDays(13) reissueServicePublicKeyDigest shouldBe testReissueServicePublicKeyDigestByteString } } @@ -94,9 +94,9 @@ class CovidCertificateConfigMapperTest : BaseTest() { .build() createInstance().map(config).apply { - testCertificate.waitAfterPublicKeyRegistration shouldBe Duration.standardSeconds(10) - testCertificate.waitForRetry shouldBe Duration.standardSeconds(10) - expirationThreshold shouldBe Duration.standardDays(14) + testCertificate.waitAfterPublicKeyRegistration shouldBe Duration.ofSeconds(10) + testCertificate.waitForRetry shouldBe Duration.ofSeconds(10) + expirationThreshold shouldBe Duration.ofDays(14) reissueServicePublicKeyDigest shouldBe testReissueServicePublicKeyDigestByteString } } @@ -115,9 +115,9 @@ class CovidCertificateConfigMapperTest : BaseTest() { ) .build() createInstance().map(config).apply { - testCertificate.waitAfterPublicKeyRegistration shouldBe Duration.standardSeconds(10) - testCertificate.waitForRetry shouldBe Duration.standardSeconds(10) - expirationThreshold shouldBe Duration.standardDays(14) + testCertificate.waitAfterPublicKeyRegistration shouldBe Duration.ofSeconds(10) + testCertificate.waitForRetry shouldBe Duration.ofSeconds(10) + expirationThreshold shouldBe Duration.ofDays(14) reissueServicePublicKeyDigest shouldBe testReissueServicePublicKeyDigestByteString } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/DownloadConfigMapperTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/DownloadConfigMapperTest.kt index a048e1468ab..b7767c176ad 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/DownloadConfigMapperTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/DownloadConfigMapperTest.kt @@ -4,9 +4,9 @@ import de.rki.coronawarnapp.diagnosiskeys.server.LocationCode import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid import de.rki.coronawarnapp.server.protocols.internal.v2.KeyDownloadParameters import io.kotest.matchers.shouldBe -import org.joda.time.Duration -import org.joda.time.LocalDate -import org.joda.time.LocalTime +import java.time.Duration +import java.time.LocalDate +import java.time.LocalTime import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -69,8 +69,8 @@ class DownloadConfigMapperTest : BaseTest() { createInstance().map(rawConfig).apply { revokedDayPackages shouldBe emptyList() revokedHourPackages shouldBe emptyList() - overallDownloadTimeout shouldBe Duration.standardMinutes(8) - individualDownloadTimeout shouldBe Duration.standardSeconds(60) + overallDownloadTimeout shouldBe Duration.ofMinutes(8) + individualDownloadTimeout shouldBe Duration.ofSeconds(60) } } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapperTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapperTest.kt index 7a6e080ae54..fa3eedc4c3f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapperTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ExposureDetectionConfigMapperTest.kt @@ -3,7 +3,7 @@ package de.rki.coronawarnapp.appconfig.mapping import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid import de.rki.coronawarnapp.server.protocols.internal.v2.ExposureDetectionParameters.ExposureDetectionParametersAndroid import io.kotest.matchers.shouldBe -import org.joda.time.Duration +import java.time.Duration import org.junit.jupiter.api.Test import testhelpers.BaseTest @@ -27,7 +27,7 @@ class ExposureDetectionConfigMapperTest : BaseTest() { .setExposureDetectionParameters(exposureDetectionParameters) .build() createInstance().map(rawConfig).apply { - minTimeBetweenDetections shouldBe Duration.standardDays(1) + minTimeBetweenDetections shouldBe Duration.ofDays(1) maxExposureDetectionsPerUTCDay shouldBe 0 } } @@ -41,7 +41,7 @@ class ExposureDetectionConfigMapperTest : BaseTest() { .setExposureDetectionParameters(exposureDetectionParameters) .build() createInstance().map(rawConfig).apply { - minTimeBetweenDetections shouldBe Duration.standardHours(24 / 3) + minTimeBetweenDetections shouldBe Duration.ofHours(24 / 3) maxExposureDetectionsPerUTCDay shouldBe 3 } } @@ -55,7 +55,7 @@ class ExposureDetectionConfigMapperTest : BaseTest() { .setExposureDetectionParameters(exposureDetectionParameters) .build() createInstance().map(rawConfig).apply { - overallDetectionTimeout shouldBe Duration.standardMinutes(10) + overallDetectionTimeout shouldBe Duration.ofMinutes(10) } } @@ -68,7 +68,7 @@ class ExposureDetectionConfigMapperTest : BaseTest() { .setExposureDetectionParameters(exposureDetectionParameters) .build() createInstance().map(rawConfig).apply { - overallDetectionTimeout shouldBe Duration.standardMinutes(15) + overallDetectionTimeout shouldBe Duration.ofMinutes(15) } } @@ -77,8 +77,8 @@ class ExposureDetectionConfigMapperTest : BaseTest() { val rawConfig = AppConfigAndroid.ApplicationConfigurationAndroid.newBuilder() .build() createInstance().map(rawConfig).apply { - overallDetectionTimeout shouldBe Duration.standardMinutes(15) - minTimeBetweenDetections shouldBe Duration.standardHours(24 / 6) + overallDetectionTimeout shouldBe Duration.ofMinutes(15) + minTimeBetweenDetections shouldBe Duration.ofHours(24 / 6) maxExposureDetectionsPerUTCDay shouldBe 6 } } 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 57f0f175409..602439793c1 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 @@ -13,8 +13,8 @@ import io.mockk.every import io.mockk.impl.annotations.MockK import kotlinx.coroutines.test.runTest import okio.ByteString.Companion.decodeHex -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorageTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorageTest.kt index a8bf0d19cad..21370352698 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorageTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/AppConfigStorageTest.kt @@ -12,8 +12,8 @@ import io.mockk.mockk import kotlinx.coroutines.test.runTest import okio.ByteString.Companion.decodeHex import okio.ByteString.Companion.toByteString -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -35,9 +35,9 @@ class AppConfigStorageTest : BaseIOTest() { private val testConfigDownload = InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T05:35:16.000Z"), - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(123) + cacheValidity = Duration.ofSeconds(123) ) @BeforeEach @@ -45,7 +45,7 @@ class AppConfigStorageTest : BaseIOTest() { MockKAnnotations.init(this) every { context.filesDir } returns privateFiles - every { timeStamper.nowUTC } returns Instant.ofEpochMilli(1234) + every { timeStamper.nowJavaUTC } returns Instant.ofEpochMilli(1234) } @AfterEach @@ -163,7 +163,7 @@ class AppConfigStorageTest : BaseIOTest() { serverTime = Instant.ofEpochMilli(legacyConfigPath.lastModified()), localOffset = Duration.ZERO, etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(0) + cacheValidity = Duration.ofSeconds(0) ) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/LocalAppConfigSourceTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/LocalAppConfigSourceTest.kt index 3e878ba71e0..34165f9b1ef 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/LocalAppConfigSourceTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/local/LocalAppConfigSourceTest.kt @@ -14,8 +14,8 @@ import io.mockk.impl.annotations.MockK import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest import okio.ByteString.Companion.decodeHex -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -36,9 +36,9 @@ class LocalAppConfigSourceTest : BaseIOTest() { private var expectedData = InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T05:35:16.000Z"), - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), etag = "etag", - cacheValidity = Duration.standardMinutes(5) + cacheValidity = Duration.ofMinutes(5) ) private var mockConfigStorage: InternalConfigData? = null @@ -56,7 +56,7 @@ class LocalAppConfigSourceTest : BaseIOTest() { every { configParser.parse(APPCONFIG_RAW) } returns configData - every { timeStamper.nowUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") + every { timeStamper.nowJavaUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") } @AfterEach @@ -93,7 +93,7 @@ class LocalAppConfigSourceTest : BaseIOTest() { mappedConfig = configData, configType = ConfigData.Type.LAST_RETRIEVED, identifier = expectedData.etag, - cacheValidity = Duration.standardMinutes(5) + cacheValidity = Duration.ofMinutes(5) ) coVerifyOrder { configStorage.getStoredConfig() } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServerTest.kt index 378c648c162..cccd5e20d7b 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/AppConfigServerTest.kt @@ -20,8 +20,8 @@ import kotlinx.coroutines.test.runTest import okhttp3.Headers import okhttp3.ResponseBody.Companion.toResponseBody import okio.ByteString.Companion.decodeHex -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -44,7 +44,7 @@ class AppConfigServerTest : BaseIOTest() { testDir.mkdirs() testDir.exists() shouldBe true - every { timeStamper.nowUTC } returns Instant.ofEpochMilli(123456789) + every { timeStamper.nowJavaUTC } returns Instant.ofEpochMilli(123456789) every { signatureValidation.hasValidSignature(any(), any()) } returns true mockkObject(CWADebug) @@ -84,12 +84,12 @@ class AppConfigServerTest : BaseIOTest() { configDownload shouldBe InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T08:46:03.000Z"), - localOffset = Duration( + localOffset = Duration.between( Instant.parse("2020-11-03T08:46:03.000Z"), Instant.ofEpochMilli(123456789) ), etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(123) + cacheValidity = Duration.ofSeconds(123) ) verify(exactly = 1) { signatureValidation.hasValidSignature(any(), any()) } @@ -140,7 +140,7 @@ class AppConfigServerTest : BaseIOTest() { serverTime = Instant.ofEpochMilli(123456789), localOffset = Duration.ZERO, etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) } @@ -168,16 +168,16 @@ class AppConfigServerTest : BaseIOTest() { "I am an ETag :)!" ) ) - every { timeStamper.nowUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") + every { timeStamper.nowJavaUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") val downloadServer = createInstance() downloadServer.downloadAppConfig() shouldBe InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T06:35:16.000Z"), - localOffset = Duration.standardHours(-1), + localOffset = Duration.ofHours(-1), etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) } @@ -192,7 +192,7 @@ class AppConfigServerTest : BaseIOTest() { "I am an ETag :)!" ) ) - every { timeStamper.nowUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") + every { timeStamper.nowJavaUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") every { CWADebug.isDeviceForTestersBuild } returns true every { testSettings.fakeCorrectDeviceTime } returns mockFlowPreference(true) @@ -201,7 +201,7 @@ class AppConfigServerTest : BaseIOTest() { serverTime = Instant.parse("2020-11-03T06:35:16.000Z"), localOffset = Duration.ZERO, etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) } @@ -216,16 +216,16 @@ class AppConfigServerTest : BaseIOTest() { "I am an ETag :)!" ) ) - every { timeStamper.nowUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") + every { timeStamper.nowJavaUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") every { CWADebug.isDeviceForTestersBuild } returns false every { testSettings.fakeCorrectDeviceTime } returns mockFlowPreference(true) createInstance().downloadAppConfig() shouldBe InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T06:35:16.000Z"), - localOffset = Duration.standardHours(-1), + localOffset = Duration.ofHours(-1), etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) } @@ -249,12 +249,12 @@ class AppConfigServerTest : BaseIOTest() { configDownload shouldBe InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T08:46:03.000Z"), - localOffset = Duration( + localOffset = Duration.between( Instant.parse("2020-11-03T08:46:03.000Z"), Instant.ofEpochMilli(123456789) ), etag = "I am an ETag :)!", - cacheValidity = Duration.standardSeconds(300) + cacheValidity = Duration.ofSeconds(300) ) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/RemoteAppConfigSourceTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/RemoteAppConfigSourceTest.kt index 28e4d543231..d852d9e008c 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/RemoteAppConfigSourceTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/sources/remote/RemoteAppConfigSourceTest.kt @@ -15,8 +15,8 @@ import io.mockk.impl.annotations.MockK import io.mockk.verify import okhttp3.Cache import okio.ByteString.Companion.decodeHex -import org.joda.time.Duration -import org.joda.time.Instant +import java.time.Duration +import java.time.Instant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -40,9 +40,9 @@ class RemoteAppConfigSourceTest : BaseIOTest() { private var dataFromServer = InternalConfigData( rawData = APPCONFIG_RAW, serverTime = Instant.parse("2020-11-03T05:35:16.000Z"), - localOffset = Duration.standardHours(1), + localOffset = Duration.ofHours(1), etag = "etag", - cacheValidity = Duration.standardSeconds(420) + cacheValidity = Duration.ofSeconds(420) ) private var mockConfigStorage: InternalConfigData? = null @@ -62,7 +62,7 @@ class RemoteAppConfigSourceTest : BaseIOTest() { every { configParser.parse(APPCONFIG_RAW) } returns configData - every { timeStamper.nowUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") + every { timeStamper.nowJavaUTC } returns Instant.parse("2020-11-03T05:35:16.000Z") } @AfterEach @@ -87,7 +87,7 @@ class RemoteAppConfigSourceTest : BaseIOTest() { mappedConfig = configData, configType = ConfigData.Type.FROM_SERVER, identifier = "etag", - cacheValidity = Duration.standardSeconds(420) + cacheValidity = Duration.ofSeconds(420) ) mockConfigStorage shouldBe dataFromServer diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RapidAntigenCoronaTestExtensionsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RapidAntigenCoronaTestExtensionsTest.kt index db84bd74595..02414e4fc14 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RapidAntigenCoronaTestExtensionsTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/coronatest/type/rapidantigen/RapidAntigenCoronaTestExtensionsTest.kt @@ -27,7 +27,7 @@ class RapidAntigenCoronaTestExtensionsTest : BaseTest() { every { timeStamper.nowUTC } returns Instant.ofEpochMilli(1010010101) every { coronaTestConfig.ratParameters.hoursToDeemTestOutdated } returns - Duration.standardHours(48) + java.time.Duration.ofHours(48) } @Test diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateCheckerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateCheckerTest.kt index 381f9627837..6cf5b030b09 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateCheckerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccStateCheckerTest.kt @@ -45,7 +45,7 @@ class DccStateCheckerTest : BaseTest() { MockKAnnotations.init(this) every { configData.covidCertificateParameters } returns covidCertificateConfig - every { covidCertificateConfig.expirationThreshold } returns Duration.standardDays(10) + every { covidCertificateConfig.expirationThreshold } returns java.time.Duration.ofDays(10) every { timeStamper.nowUTC } returns Instant.ofEpochSecond(1234567890) coEvery { appConfigProvider.currentConfig } returns flowOf(configData) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessorTest.kt index 7d1d06f0d6e..aacfdbdee06 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateProcessorTest.kt @@ -28,7 +28,7 @@ import io.mockk.mockk import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import okio.ByteString -import org.joda.time.Duration +import java.time.Duration import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -87,6 +87,7 @@ class TestCertificateProcessorTest : BaseTest() { MockKAnnotations.init(this) every { timeStamper.nowUTC } returns Instant.ofEpochSecond(1234567) + every { timeStamper.nowJavaUTC } returns java.time.Instant.ofEpochSecond(1234567) every { appConfigProvider.currentConfig } returns flowOf(appConfigData) every { appConfigData.covidCertificateParameters } returns mockk().apply { @@ -94,8 +95,8 @@ class TestCertificateProcessorTest : BaseTest() { } covidTestCertificateConfig.apply { - every { waitForRetry } returns Duration.standardSeconds(10) - every { waitAfterPublicKeyRegistration } returns Duration.standardSeconds(10) + every { waitForRetry } returns java.time.Duration.ofSeconds(10) + every { waitAfterPublicKeyRegistration } returns Duration.ofSeconds(10) } certificateServer.apply { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateRepositoryTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateRepositoryTest.kt index f19ce21c36f..4199e92c6ce 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateRepositoryTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/covidcertificate/test/core/TestCertificateRepositoryTest.kt @@ -37,7 +37,7 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest -import org.joda.time.Duration +import java.time.Duration import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -80,8 +80,8 @@ class TestCertificateRepositoryTest : BaseTest() { } returns CwaCovidCertificate.State.Invalid() covidTestCertificateConfig.apply { - every { waitForRetry } returns Duration.standardSeconds(10) - every { waitAfterPublicKeyRegistration } returns Duration.standardSeconds(10) + every { waitForRetry } returns Duration.ofSeconds(10) + every { waitAfterPublicKeyRegistration } returns Duration.ofSeconds(10) } storage.apply { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNetTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNetTest.kt index 224ef49f8a5..97c77d5361b 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNetTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/datadonation/safetynet/CWASafetyNetTest.kt @@ -82,11 +82,7 @@ class CWASafetyNetTest : BaseTest() { coEvery { appConfigProvider.getAppConfig() } returns appConfigData every { appConfigData.deviceTimeState } returns ConfigData.DeviceTimeState.CORRECT - every { cwaSettings.firstReliableDeviceTime } returns org.joda.time.Instant.EPOCH.plus( - org.joda.time.Duration.standardDays( - 7 - ) - ) + every { cwaSettings.firstReliableDeviceTime } returns Instant.EPOCH.plus(Duration.ofDays(7)) every { timeStamper.nowJavaUTC } returns Instant.EPOCH.plus(Duration.ofDays(8)) every { testSettings.skipSafetyNetTimeCheck } returns mockFlowPreference(false) @@ -255,7 +251,7 @@ class CWASafetyNetTest : BaseTest() { @Test fun `first reliable devicetime timestamp needs to be set`() = runTest { - every { cwaSettings.firstReliableDeviceTime } returns org.joda.time.Instant.EPOCH + every { cwaSettings.firstReliableDeviceTime } returns Instant.EPOCH val exception = shouldThrow { createInstance().attest(TestAttestationRequest("Computer says no.".toByteArray())) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DayPackageSyncToolTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DayPackageSyncToolTest.kt index fd85b63fdda..f7f14b9be6d 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DayPackageSyncToolTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DayPackageSyncToolTest.kt @@ -2,6 +2,7 @@ package de.rki.coronawarnapp.diagnosiskeys.download import de.rki.coronawarnapp.appconfig.mapping.RevokedKeyPackage import de.rki.coronawarnapp.diagnosiskeys.storage.CachedKeyInfo.Type +import de.rki.coronawarnapp.util.toJavaTime import io.kotest.matchers.shouldBe import io.mockk.coEvery import io.mockk.coVerify @@ -143,7 +144,7 @@ class DayPackageSyncToolTest : CommonSyncToolTest() { every { downloadConfig.revokedDayPackages } returns listOf( RevokedKeyPackage.Day( - day = invalidDay.info.day, + day = invalidDay.info.day.toJavaTime(), region = invalidDay.info.location, etag = invalidDay.info.etag!! ) @@ -177,7 +178,7 @@ class DayPackageSyncToolTest : CommonSyncToolTest() { mockCachedDay("EUR".loc, "2020-01-03".day).apply { every { downloadConfig.revokedDayPackages } returns listOf( RevokedKeyPackage.Day( - day = info.day, + day = info.day.toJavaTime(), region = info.location, etag = info.etag!! ) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTaskTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTaskTest.kt index 25146223282..35168aa3eb6 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTaskTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/DownloadDiagnosisKeysTaskTest.kt @@ -69,7 +69,7 @@ class DownloadDiagnosisKeysTaskTest : BaseTest() { appConfig.apply { every { maxExposureDetectionsPerUTCDay } returns 5 - every { minTimeBetweenDetections } returns Duration.standardHours(24 / 6) + every { minTimeBetweenDetections } returns java.time.Duration.ofHours(24 / 6) every { diagnosisKeysDataMapping } returns diagnosisKeyDataMapping every { isDeviceTimeCorrect } returns true } @@ -233,7 +233,7 @@ class DownloadDiagnosisKeysTaskTest : BaseTest() { @Test fun `we do not submit keys if device time is incorrect`() = runTest { every { appConfig.isDeviceTimeCorrect } returns false - every { appConfig.localOffset } returns Duration.standardHours(5) + every { appConfig.localOffset } returns java.time.Duration.ofHours(5) createInstance().run(DownloadDiagnosisKeysTask.Arguments()) 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 6cd17569fbb..4691ee9c82c 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 @@ -3,6 +3,7 @@ package de.rki.coronawarnapp.diagnosiskeys.download import de.rki.coronawarnapp.appconfig.mapping.RevokedKeyPackage import de.rki.coronawarnapp.diagnosiskeys.storage.CachedKeyInfo.Type import de.rki.coronawarnapp.exception.http.NetworkConnectTimeoutException +import de.rki.coronawarnapp.util.toJavaTime import io.kotest.matchers.shouldBe import io.mockk.coEvery import io.mockk.coVerify @@ -15,6 +16,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import testhelpers.TestDispatcherProvider import java.io.IOException +import java.time.LocalTime class HourPackageSyncToolTest : CommonSyncToolTest() { @@ -88,8 +90,8 @@ class HourPackageSyncToolTest : CommonSyncToolTest() { every { downloadConfig.revokedHourPackages } returns listOf( RevokedKeyPackage.Hour( - day = invalidHour.info.day, - hour = invalidHour.info.hour!!, + day = invalidHour.info.day.toJavaTime(), + hour = LocalTime.of(invalidHour.info.hour!!.hourOfDay, 0), region = invalidHour.info.location, etag = invalidHour.info.etag!! ) @@ -222,8 +224,8 @@ class HourPackageSyncToolTest : CommonSyncToolTest() { RevokedKeyPackage.Hour( region = info.location, etag = info.etag!!, - day = info.day, - hour = info.hour!! + day = info.day.toJavaTime(), + hour = LocalTime.of(info.hour!!.hourOfDay, 0) ) ) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadToolTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadToolTest.kt index e26f6d404f1..f63b017c29a 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadToolTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/diagnosiskeys/download/KeyDownloadToolTest.kt @@ -22,7 +22,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest import okhttp3.Headers -import org.joda.time.Duration +import java.time.Duration import org.joda.time.Instant import org.joda.time.LocalDate import org.joda.time.LocalTime @@ -65,7 +65,7 @@ class KeyDownloadToolTest : BaseIOTest() { every { cachedKey.path } returns testFile every { cachedKey.info } returns cachedKeyInfo - every { downloadConfig.individualDownloadTimeout } returns Duration.millis(9000L) + every { downloadConfig.individualDownloadTimeout } returns Duration.ofMillis(9000L) coEvery { keyCache.markKeyComplete(any(), any()) } just Runs coEvery { keyCache.deleteInfoAndFile(any()) } just Runs diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/main/CWASettingsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/main/CWASettingsTest.kt index eb223628fbc..d3f73639c14 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/main/CWASettingsTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/main/CWASettingsTest.kt @@ -45,11 +45,11 @@ class CWASettingsTest : BaseTest() { createInstance().apply { preferences.dataMapPeek.isEmpty() shouldBe true - firstReliableDeviceTime shouldBe Instant.EPOCH - firstReliableDeviceTime = Instant.ofEpochMilli(12345L) + firstReliableDeviceTime shouldBe java.time.Instant.EPOCH + firstReliableDeviceTime = java.time.Instant.ofEpochMilli(12345L) preferences.dataMapPeek["devicetime.correct.first"] shouldBe 12345L - firstReliableDeviceTime = Instant.ofEpochMilli(9999L) + firstReliableDeviceTime = java.time.Instant.ofEpochMilli(9999L) preferences.dataMapPeek["devicetime.correct.first"] shouldBe 9999L } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTrackerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTrackerTest.kt index 521b32e461c..328cfe6679f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTrackerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/nearby/modules/detectiontracker/DefaultExposureDetectionTrackerTest.kt @@ -4,6 +4,7 @@ import de.rki.coronawarnapp.appconfig.AppConfigProvider import de.rki.coronawarnapp.appconfig.ConfigData import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.mutate +import de.rki.coronawarnapp.util.toJavaInstant import io.kotest.matchers.shouldBe import io.mockk.Called import io.mockk.MockKAnnotations @@ -41,11 +42,12 @@ class DefaultExposureDetectionTrackerTest : BaseTest() { MockKAnnotations.init(this) every { timeStamper.nowUTC } returns Instant.EPOCH + every { timeStamper.nowJavaUTC } returns Instant.EPOCH.toJavaInstant() coEvery { storage.load() } returns emptyMap() coEvery { storage.save(any()) } just Runs coEvery { configProvider.currentConfig } returns flowOf(appConfigData) - every { appConfigData.overallDetectionTimeout } returns Duration.standardMinutes(15) + every { appConfigData.overallDetectionTimeout } returns java.time.Duration.ofMinutes(15) } private fun createInstance(scope: CoroutineScope) = DefaultExposureDetectionTracker( @@ -199,6 +201,9 @@ class DefaultExposureDetectionTrackerTest : BaseTest() { every { timeStamper.nowUTC } returns Instant.EPOCH .plus(Duration.standardMinutes(15)) .plus(2) + every { timeStamper.nowJavaUTC } returns Instant.EPOCH + .plus(Duration.standardMinutes(15)) + .plus(2).toJavaInstant() // First half will be in the timeout, last half will be ok val timeoutOnRunningCalc = TrackedExposureDetection( 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 0ffac83f15c..721686295e8 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 @@ -39,7 +39,7 @@ import io.mockk.mockk import kotlinx.coroutines.flow.flow import kotlinx.coroutines.test.runTest import org.joda.time.DateTimeConstants -import org.joda.time.Duration +import java.time.Duration import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -325,8 +325,8 @@ class ExposureWindowsCalculationTest : BaseTest() { private fun setupTestConfiguration(json: DefaultRiskCalculationConfiguration) { testConfig = ConfigDataContainer( - serverTime = Instant.now(), - cacheValidity = Duration.standardMinutes(5), + serverTime = java.time.Instant.now(), + cacheValidity = Duration.ofMinutes(5), localOffset = Duration.ZERO, mappedConfig = configData, identifier = "soup", diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/EwRiskLevelTaskTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/EwRiskLevelTaskTest.kt index 95a451affdb..2e68a042b5a 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/EwRiskLevelTaskTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/EwRiskLevelTaskTest.kt @@ -15,6 +15,7 @@ import de.rki.coronawarnapp.task.Task import de.rki.coronawarnapp.task.TaskCancellationException import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.device.BackgroundModeStatus +import de.rki.coronawarnapp.util.toJoda import io.kotest.matchers.shouldBe import io.mockk.MockKAnnotations import io.mockk.Runs @@ -29,7 +30,7 @@ import io.mockk.verify import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import org.joda.time.DateTime -import org.joda.time.Duration +import java.time.Duration import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -129,9 +130,9 @@ class EwRiskLevelTaskTest : BaseTest() { @Test fun `risk calculation is skipped if device time is incorrect`() = runTest { every { configData.isDeviceTimeCorrect } returns false - every { configData.localOffset } returns Duration.standardHours(5) + every { configData.localOffset } returns Duration.ofHours(5) - val serverTime = testTimeNow.minus(configData.localOffset) + val serverTime = testTimeNow.minus(configData.localOffset.toJoda()) createTask().run(arguments) shouldBe EwRiskLevelTaskResult( calculatedAt = serverTime, diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfoTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfoTest.kt index 9e74d088aa9..cc5e1c54ce0 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfoTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/risk/RiskCardDisplayInfoTest.kt @@ -15,7 +15,7 @@ import io.mockk.impl.annotations.MockK import io.mockk.mockk import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest -import org.joda.time.Duration +import java.time.Duration import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.extension.ExtensionContext @@ -39,10 +39,10 @@ internal class RiskCardDisplayInfoTest : BaseTest() { val configData = mockk { every { coronaTestParameters } returns mockk { every { ratParameters } returns mockk { - every { durationToShowRiskCard } returns Duration.standardHours(1) + every { durationToShowRiskCard } returns Duration.ofHours(1) } every { pcrParameters } returns mockk { - every { durationToShowRiskCard } returns Duration.standardHours(1) + every { durationToShowRiskCard } returns Duration.ofHours(1) } } } @@ -55,7 +55,7 @@ internal class RiskCardDisplayInfoTest : BaseTest() { runTest { with(testCase) { every { testRepository.coronaTests } returns flowOf(testSet) - every { timeStamper.nowUTC } returns Instant.EPOCH.plus(durationPassed) + every { timeStamper.nowJavaUTC } returns java.time.Instant.EPOCH.plus(durationPassed) createInstance().shouldShowRiskCard(riskState) shouldBe showRiskCardExpectedReturnValue } } @@ -128,19 +128,19 @@ internal class RiskCardDisplayInfoTest : BaseTest() { TestCase( riskState = RiskState.LOW_RISK, testSet = setOf(positiveRatTest), - durationPassed = Duration.standardHours(1).minus(Duration.standardSeconds(1)), + durationPassed = Duration.ofHours(1).minus(Duration.ofSeconds(1)), showRiskCardExpectedReturnValue = false ), TestCase( riskState = RiskState.LOW_RISK, testSet = setOf(positivePcrTest), - durationPassed = Duration.standardHours(1).minus(Duration.standardSeconds(1)), + durationPassed = Duration.ofHours(1).minus(Duration.ofSeconds(1)), showRiskCardExpectedReturnValue = false ), TestCase( riskState = RiskState.LOW_RISK, testSet = setOf(positiveRatTest, positivePcrTest), - durationPassed = Duration.standardHours(1).minus(Duration.standardSeconds(1)), + durationPassed = Duration.ofHours(1).minus(Duration.ofSeconds(1)), showRiskCardExpectedReturnValue = false ), @@ -148,19 +148,19 @@ internal class RiskCardDisplayInfoTest : BaseTest() { TestCase( riskState = RiskState.LOW_RISK, testSet = setOf(positiveRatTest), - durationPassed = Duration.standardHours(1), + durationPassed = Duration.ofHours(1), showRiskCardExpectedReturnValue = true ), TestCase( riskState = RiskState.LOW_RISK, testSet = setOf(positivePcrTest), - durationPassed = Duration.standardHours(1), + durationPassed = Duration.ofHours(1), showRiskCardExpectedReturnValue = true ), TestCase( riskState = RiskState.LOW_RISK, testSet = setOf(positiveRatTest, positivePcrTest), - durationPassed = Duration.standardHours(1), + durationPassed = Duration.ofHours(1), showRiskCardExpectedReturnValue = true ), @@ -174,13 +174,13 @@ internal class RiskCardDisplayInfoTest : BaseTest() { TestCase( riskState = RiskState.CALCULATION_FAILED, testSet = setOf(positivePcrTest), - durationPassed = Duration.standardHours(1).minus(Duration.standardSeconds(1)), + durationPassed = Duration.ofHours(1).minus(Duration.ofSeconds(1)), showRiskCardExpectedReturnValue = false ), TestCase( riskState = RiskState.CALCULATION_FAILED, testSet = setOf(positiveRatTest, positivePcrTest), - durationPassed = Duration.standardHours(1), + durationPassed = Duration.ofHours(1), showRiskCardExpectedReturnValue = true ), @@ -194,13 +194,13 @@ internal class RiskCardDisplayInfoTest : BaseTest() { TestCase( riskState = null, testSet = setOf(positivePcrTest), - durationPassed = Duration.standardHours(1).minus(Duration.standardSeconds(1)), + durationPassed = Duration.ofHours(1).minus(Duration.ofSeconds(1)), showRiskCardExpectedReturnValue = false ), TestCase( riskState = null, testSet = setOf(positiveRatTest, positivePcrTest), - durationPassed = Duration.standardHours(1), + durationPassed = Duration.ofHours(1), showRiskCardExpectedReturnValue = true ), ).map { Arguments.of(it) }.stream()