From 960eae90164c401bb56c528ea7b279e6c3bea843 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Wed, 11 May 2022 10:39:13 +0200 Subject: [PATCH 01/16] add accompanying certificates button --- .../calculation/DccWalletInfoCalculation.kt | 21 +++++++----- .../consent/DccReissuanceConsentFragment.kt | 11 ++++++ .../consent/DccReissuanceConsentViewModel.kt | 32 +++++++++-------- .../fragment_dcc_reissuance_consent.xml | 34 ++++++++++++++++++- .../res/values-de/dcc_reissuance_strings.xml | 1 + .../res/values/dcc_reissuance_strings.xml | 1 + 6 files changed, 75 insertions(+), 25 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt index daaaad89c69..f478ddd41d9 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt @@ -21,7 +21,6 @@ import de.rki.coronawarnapp.util.serialization.BaseGson import de.rki.coronawarnapp.util.serialization.BaseJackson import kotlinx.coroutines.withContext import org.joda.time.DateTime -import timber.log.Timber import javax.inject.Inject class DccWalletInfoCalculation @Inject constructor( @@ -45,18 +44,22 @@ class DccWalletInfoCalculation @Inject constructor( admissionScenarioId: String = "", dateTime: DateTime = DateTime.now() ): DccWalletInfo = withContext(dispatcherProvider.IO) { + val input = getDccWalletInfoInput( + dccList = dccList, + boosterNotificationRules = boosterRulesNode, + defaultInputParameters = getDefaultInputParameters(dateTime), + scenarioIdentifier = admissionScenarioId, + invalidationRules = invalidationRulesNode + ).toJsonNode() + + //Timber.d(input.toPrettyString()) + val output = cclJsonFunctions.evaluateFunction( "getDccWalletInfo", - getDccWalletInfoInput( - dccList = dccList, - boosterNotificationRules = boosterRulesNode, - defaultInputParameters = getDefaultInputParameters(dateTime), - scenarioIdentifier = admissionScenarioId, - invalidationRules = invalidationRulesNode - ).toJsonNode() + input ) - Timber.d(output.toPrettyString()) + //Timber.d(output.toPrettyString()) mapper.treeToValue(output, DccWalletInfo::class.java) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt index 9da2fae9941..f7910b0959a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt @@ -2,6 +2,7 @@ package de.rki.coronawarnapp.dccreissuance.ui.consent import android.os.Bundle import android.view.View +import android.widget.Toast import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController @@ -54,6 +55,9 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c agreeButton.defaultButton.setOnClickListener { viewModel.startReissuance() } + accompanyingCertificatesGroup.setOnClickListener { + viewModel.openAccompanyingCertificatesScreen() + } certificateRecycler.apply { adapter = dccReissuanceAdapter @@ -62,6 +66,7 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c viewModel.apply { stateLiveData.observe2(this@DccReissuanceConsentFragment) { reissuanceGroup.isVisible = it.divisionVisible + accompanyingCertificatesGroup.isVisible = it.accompanyingCertificatesVisible listTitleText.text = it.listItemsTitle dccReissuanceTitle.text = it.title dccReissuanceSubtitle.text = it.subtitle @@ -95,6 +100,12 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c DccReissuanceConsentViewModel.OpenPrivacyScreen -> findNavController().navigate( R.id.informationPrivacyFragment ) + DccReissuanceConsentViewModel.OpenAccompanyingCertificatesScreen -> + Toast.makeText( + this@DccReissuanceConsentFragment.context, + "Open accompanying certificates screen", + Toast.LENGTH_SHORT + ).show() } } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt index 382922cb080..e40e439b7cf 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt @@ -39,7 +39,7 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( person?.dccWalletInfo?.certificateReissuance } internal val stateLiveData: LiveData = reissuanceData.map { - // Make sure DccReissuance exist, otherwise screen is dismissed + // Make sure DccReissuance exists, otherwise screen is dismissed it!!.toState() }.catch { Timber.tag(TAG).d(it, "dccReissuanceData failed") @@ -62,24 +62,22 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( fun navigateBack() = event.postValue(Back) private suspend fun CertificateReissuance?.toState(): State { - val certificates = mutableListOf() - if (this?.certificates != null) { - this.certificates.forEach { dccCertificate -> - - val certificateToReissue = dccQrCodeExtractor.extract( + val certificates = this?.certificates?.map { dccCertificate -> + DccReissuanceConsentCard.Item( + dccQrCodeExtractor.extract( dccCertificate.certificateToReissue.certificateRef.barcodeData, DccV1Parser.Mode.CERT_SINGLE_STRICT ).data.certificate - - certificates.add( - DccReissuanceConsentCard.Item( - certificateToReissue - ) - ) - } + ) } + + val accompanyingCertificatesVisible = this?.certificates?.any { + it.accompanyingCertificates.isNotEmpty() + } ?: false + return State( - certificateList = certificates, + certificateList = certificates ?: emptyList(), + accompanyingCertificatesVisible = accompanyingCertificatesVisible, divisionVisible = this?.reissuanceDivision?.visible ?: false, listItemsTitle = format(this?.reissuanceDivision?.listTitleText), title = format(this?.reissuanceDivision?.titleText), @@ -91,9 +89,12 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( fun openPrivacyScreen() = event.postValue(OpenPrivacyScreen) + fun openAccompanyingCertificatesScreen() = event.postValue(OpenAccompanyingCertificatesScreen) + internal data class State( val certificateList: List, - val divisionVisible: Boolean = false, + val accompanyingCertificatesVisible: Boolean, + val divisionVisible: Boolean, val listItemsTitle: String?, val title: String?, val subtitle: String?, @@ -106,6 +107,7 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( internal object ReissuanceSuccess : Event() internal object Back : Event() internal object OpenPrivacyScreen : Event() + internal object OpenAccompanyingCertificatesScreen : Event() internal data class ReissuanceError(val error: Throwable) : Event() @AssistedFactory diff --git a/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml b/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml index d3aa445d757..eb143e4f3e0 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml @@ -57,6 +57,38 @@ tools:itemCount="2" tools:listitem="@layout/dcc_reissuance_certificate_card" /> + + + + + + Das alte Zertifikat wird automatisch in den Papierkorb verschoben und nach 30 Tagen gelöscht. Das Zertifikat kann innerhalb der 30 Tage jederzeit wiederhergestellt werden. Falls Sie hier abbrechen, können Sie die Aktualisierung jederzeit in Ihrer Zertifikatsübersicht anfordern. + Zusätzlich übermittelte Zertifikate \ No newline at end of file diff --git a/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml b/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml index 2963adc29ab..283d38efcb1 100644 --- a/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml +++ b/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml @@ -29,4 +29,5 @@ "The old certificate will be moved automatically to the recycle bin and deleted after 30 days. The certificate can be restored at any time within these 30 days." "If you cancel now, you can request an update in the certificate overview at any time." + Zusätzlich übermittelte Zertifikate \ No newline at end of file From 890605facfb4683cbce88167a77bfd6a78d3edf0 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Wed, 11 May 2022 19:02:49 +0200 Subject: [PATCH 02/16] accompanying certs screen --- .../calculation/DccWalletInfoCalculation.kt | 4 - .../dccreissuance/DccReissuanceUiModule.kt | 5 ++ .../consent/DccReissuanceConsentFragment.kt | 14 ++-- .../consent/DccReissuanceConsentViewModel.kt | 15 +++- .../acccerts/DccReissuanceAccCertsFragment.kt | 61 +++++++++++++++ .../DccReissuanceAccCertsFragmentModule.kt | 19 +++++ .../DccReissuanceAccCertsViewModel.kt | 75 ++++++++++++++++++ .../fragment_dcc_reissuance_acc_certs.xml | 76 +++++++++++++++++++ .../res/layout/fragment_family_test_list.xml | 3 +- .../navigation/covid_certificates_graph.xml | 15 ++++ .../res/values-de/dcc_reissuance_strings.xml | 2 + .../res/values/dcc_reissuance_strings.xml | 2 + 12 files changed, 275 insertions(+), 16 deletions(-) create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentModule.kt create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt create mode 100644 Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_acc_certs.xml diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt index f478ddd41d9..33ecc1556fe 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/calculation/DccWalletInfoCalculation.kt @@ -52,15 +52,11 @@ class DccWalletInfoCalculation @Inject constructor( invalidationRules = invalidationRulesNode ).toJsonNode() - //Timber.d(input.toPrettyString()) - val output = cclJsonFunctions.evaluateFunction( "getDccWalletInfo", input ) - //Timber.d(output.toPrettyString()) - mapper.treeToValue(output, DccWalletInfo::class.java) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/DccReissuanceUiModule.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/DccReissuanceUiModule.kt index fc369a88f06..597c5f314bc 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/DccReissuanceUiModule.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/DccReissuanceUiModule.kt @@ -4,10 +4,15 @@ import dagger.Module import dagger.android.ContributesAndroidInjector import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentFragment import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentFragmentModule +import de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts.DccReissuanceAccCertsFragment +import de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts.DccReissuanceAccCertsFragmentModule @Module abstract class DccReissuanceUiModule { @ContributesAndroidInjector(modules = [DccReissuanceConsentFragmentModule::class]) abstract fun dccReissuanceConsentFragment(): DccReissuanceConsentFragment + + @ContributesAndroidInjector(modules = [DccReissuanceAccCertsFragmentModule::class]) + abstract fun dccReissuanceAccCertsFragment(): DccReissuanceAccCertsFragment } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt index f7910b0959a..7cc24479655 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt @@ -2,7 +2,6 @@ package de.rki.coronawarnapp.dccreissuance.ui.consent import android.os.Bundle import android.view.View -import android.widget.Toast import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController @@ -55,7 +54,7 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c agreeButton.defaultButton.setOnClickListener { viewModel.startReissuance() } - accompanyingCertificatesGroup.setOnClickListener { + accompanyingCertificatesText.setOnClickListener { viewModel.openAccompanyingCertificatesScreen() } @@ -101,11 +100,12 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c R.id.informationPrivacyFragment ) DccReissuanceConsentViewModel.OpenAccompanyingCertificatesScreen -> - Toast.makeText( - this@DccReissuanceConsentFragment.context, - "Open accompanying certificates screen", - Toast.LENGTH_SHORT - ).show() + findNavController().navigate( + DccReissuanceConsentFragmentDirections + .actionDccReissuanceConsentFragmentToAccCertsFragment( + args.personIdentifierCode + ) + ) } } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt index e40e439b7cf..2cfa6761b42 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt @@ -62,13 +62,20 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( fun navigateBack() = event.postValue(Back) private suspend fun CertificateReissuance?.toState(): State { - val certificates = this?.certificates?.map { dccCertificate -> - DccReissuanceConsentCard.Item( + val certificates = this?.certificates?.mapNotNull { dccCertificate -> + try { dccQrCodeExtractor.extract( dccCertificate.certificateToReissue.certificateRef.barcodeData, DccV1Parser.Mode.CERT_SINGLE_STRICT - ).data.certificate - ) + ).data.certificate.let { + DccReissuanceConsentCard.Item( + it + ) + } + } catch (e: Exception) { + Timber.e(e, "Failed to extract certificate") + null + } } val accompanyingCertificatesVisible = this?.certificates?.any { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt new file mode 100644 index 00000000000..e93512b0e6c --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt @@ -0,0 +1,61 @@ +package de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.Fragment +import androidx.navigation.fragment.navArgs +import com.google.android.material.transition.MaterialSharedAxis +import de.rki.coronawarnapp.R +import de.rki.coronawarnapp.databinding.FragmentDccReissuanceAccCertsBinding +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceAdapter +import de.rki.coronawarnapp.util.di.AutoInject +import de.rki.coronawarnapp.util.lists.diffutil.update +import de.rki.coronawarnapp.util.ui.observe2 +import de.rki.coronawarnapp.util.ui.popBackStack +import de.rki.coronawarnapp.util.ui.viewBinding +import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactoryProvider +import de.rki.coronawarnapp.util.viewmodel.cwaViewModelsAssisted +import javax.inject.Inject + +class DccReissuanceAccCertsFragment : Fragment(R.layout.fragment_dcc_reissuance_acc_certs), AutoInject { + + @Inject lateinit var viewModelFactory: CWAViewModelFactoryProvider.Factory + private val binding: FragmentDccReissuanceAccCertsBinding by viewBinding() + private val args by navArgs() + private val viewModel: DccReissuanceAccCertsViewModel by cwaViewModelsAssisted( + factoryProducer = { viewModelFactory }, + constructorCall = { factory, _ -> + factory as DccReissuanceAccCertsViewModel.Factory + factory.create( + personIdentifierCode = args.personIdentifierCode, + ) + } + ) + + private val dccReissuanceAdapter = DccReissuanceAdapter() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + enterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true) + returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.apply { + toolbar.setNavigationOnClickListener { popBackStack() } + + certificateRecycler.apply { + adapter = dccReissuanceAdapter + } + + viewModel.apply { + certificatesLiveData.observe2(this@DccReissuanceAccCertsFragment) { + dccReissuanceAdapter.update(it) + } + } + } + } +} diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentModule.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentModule.kt new file mode 100644 index 00000000000..dd674768ca7 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentModule.kt @@ -0,0 +1,19 @@ +package de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts + +import dagger.Binds +import dagger.Module +import dagger.multibindings.IntoMap +import de.rki.coronawarnapp.util.viewmodel.CWAViewModel +import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactory +import de.rki.coronawarnapp.util.viewmodel.CWAViewModelKey + +@Module +abstract class DccReissuanceAccCertsFragmentModule { + + @Binds + @IntoMap + @CWAViewModelKey(DccReissuanceAccCertsViewModel::class) + abstract fun dccReissuanceConsentFragment( + factory: DccReissuanceAccCertsViewModel.Factory + ): CWAViewModelFactory +} diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt new file mode 100644 index 00000000000..d36f948d9c9 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -0,0 +1,75 @@ +package de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts + +import androidx.lifecycle.LiveData +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import de.rki.coronawarnapp.ccl.dccwalletinfo.model.CertificateReissuance +import de.rki.coronawarnapp.covidcertificate.common.certificate.DccQrCodeExtractor +import de.rki.coronawarnapp.covidcertificate.common.certificate.DccV1Parser +import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesProvider +import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesSettings +import de.rki.coronawarnapp.covidcertificate.recovery.core.qrcode.RecoveryCertificateQRCode +import de.rki.coronawarnapp.covidcertificate.test.core.qrcode.TestCertificateQRCode +import de.rki.coronawarnapp.covidcertificate.vaccination.core.qrcode.VaccinationCertificateQRCode +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentCard +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceItem +import de.rki.coronawarnapp.util.TimeAndDateExtensions.toLocalDateUserTz +import de.rki.coronawarnapp.util.coroutine.DispatcherProvider +import de.rki.coronawarnapp.util.viewmodel.CWAViewModel +import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactory +import kotlinx.coroutines.flow.map +import timber.log.Timber + +class DccReissuanceAccCertsViewModel @AssistedInject constructor( + dispatcherProvider: DispatcherProvider, + personCertificatesProvider: PersonCertificatesProvider, + @Assisted private val personIdentifierCode: String, + private val dccQrCodeExtractor: DccQrCodeExtractor, + private val personCertificatesSettings: PersonCertificatesSettings, +) : CWAViewModel(dispatcherProvider) { + + private val reissuanceData = personCertificatesProvider.findPersonByIdentifierCode(personIdentifierCode) + .map { person -> + person?.personIdentifier?.let { personCertificatesSettings.dismissReissuanceBadge(it) } + person?.dccWalletInfo?.certificateReissuance + } + + internal val certificatesLiveData: LiveData> = reissuanceData.map { + it?.toList() ?: emptyList() + }.asLiveData2() + + private suspend fun CertificateReissuance?.toList(): List { + return (this?.certificates?: emptyList()).flatMap { + it.accompanyingCertificates + }.toSet().mapNotNull { + try { + dccQrCodeExtractor.extract( + it.certificateRef.barcodeData, + DccV1Parser.Mode.CERT_SINGLE_STRICT + ) + } catch (e: Exception) { + Timber.e(e, "Failed to extract certificate") + null + } + }.sortedByDescending { + when(it) { + is TestCertificateQRCode -> it.data.certificate.test.sampleCollectedAt?.toLocalDateUserTz() + is VaccinationCertificateQRCode -> it.data.certificate.vaccination.vaccinatedOn + is RecoveryCertificateQRCode -> it.data.certificate.recovery.testedPositiveOn + else -> null + } + }.map { + DccReissuanceConsentCard.Item( + it.data.certificate + ) + } + } + + @AssistedFactory + interface Factory : CWAViewModelFactory { + fun create( + personIdentifierCode: String + ): DccReissuanceAccCertsViewModel + } +} diff --git a/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_acc_certs.xml b/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_acc_certs.xml new file mode 100644 index 00000000000..857ba5eb546 --- /dev/null +++ b/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_acc_certs.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Corona-Warn-App/src/main/res/layout/fragment_family_test_list.xml b/Corona-Warn-App/src/main/res/layout/fragment_family_test_list.xml index 59bf0e7df06..8db0b6d2f70 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_family_test_list.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_family_test_list.xml @@ -23,7 +23,8 @@ android:layout_height="wrap_content" android:gravity="top" android:maxLines="2" - android:paddingBottom="5dp" + android:paddingVertical="4dp" + android:ellipsize="end" android:text="@string/family_tests_list_title" android:textColor="@color/colorQrCodeScanToolbar" /> diff --git a/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml b/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml index f97ca404492..ef2d1fba928 100644 --- a/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml +++ b/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml @@ -350,6 +350,21 @@ android:id="@+id/action_dccReissuanceConsentFragment_to_informationPrivacyFragment" app:destination="@id/informationPrivacyFragment" /> + + + + + + + Falls Sie hier abbrechen, können Sie die Aktualisierung jederzeit in Ihrer Zertifikatsübersicht anfordern. Zusätzlich übermittelte Zertifikate + Folgende Zertifikate werden bei der Erneuerung als Zusatzinformation übermittelt, damit die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufgenommen werden kann. Diese Zertifikate verbleiben unverändert auf Ihrem Gerät. + Zusätzlich übermittelte Zertifikate \ No newline at end of file diff --git a/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml b/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml index 283d38efcb1..4fbb17e6c76 100644 --- a/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml +++ b/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml @@ -30,4 +30,6 @@ "If you cancel now, you can request an update in the certificate overview at any time." Zusätzlich übermittelte Zertifikate + Folgende Zertifikate werden bei der Erneuerung als Zusatzinformation übermittelt, damit die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufgenommen werden kann. Diese Zertifikate verbleiben unverändert auf Ihrem Gerät. + Zusätzlich übermittelte Zertifikate \ No newline at end of file From d0d1a756425c8f605e67ce74b532b69d71fd6d43 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Wed, 11 May 2022 19:07:36 +0200 Subject: [PATCH 03/16] klint --- .../ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt index d36f948d9c9..710478c32d5 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -40,7 +40,7 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( }.asLiveData2() private suspend fun CertificateReissuance?.toList(): List { - return (this?.certificates?: emptyList()).flatMap { + return (this?.certificates ?: emptyList()).flatMap { it.accompanyingCertificates }.toSet().mapNotNull { try { @@ -53,16 +53,14 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( null } }.sortedByDescending { - when(it) { + when (it) { is TestCertificateQRCode -> it.data.certificate.test.sampleCollectedAt?.toLocalDateUserTz() is VaccinationCertificateQRCode -> it.data.certificate.vaccination.vaccinatedOn is RecoveryCertificateQRCode -> it.data.certificate.recovery.testedPositiveOn else -> null } }.map { - DccReissuanceConsentCard.Item( - it.data.certificate - ) + DccReissuanceConsentCard.Item(it.data.certificate) } } From fec0a1fdfb78bb644e3e3c6cea2605c922eb20db Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 07:42:34 +0200 Subject: [PATCH 04/16] strings --- .../fragment_dcc_reissuance_consent.xml | 25 ++++++++++++++++++- .../res/values-de/dcc_reissuance_strings.xml | 9 ++++++- .../res/values/dcc_reissuance_strings.xml | 7 ++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml b/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml index eb143e4f3e0..313253bc42c 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_dcc_reissuance_consent.xml @@ -249,6 +249,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/dcc_reissuance_consent" /> + + + + + diff --git a/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml b/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml index 28dcef3d4fb..1a8f7077b91 100644 --- a/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml +++ b/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml @@ -25,12 +25,19 @@ Die Aktualisierung des Zertifikats ist freiwillig und kostenlos. - Um sicherzustellen, dass Zertifikate nur einmalig aktualisiert werden können, wird die Kennung des alten Zertifikats durch das RKI dokumentiert. + Um sicherzustellen, dass Zertifikate nur einmalig erneuert werden können, werden jeweils die Kennung des alten und des erneuerten Zertifikats durch das RKI dokumentiert. Die weiteren Daten zu Ihren Zertifikaten werden nach der Erneuerung beim RKI sofort gelöscht. Das alte Zertifikat wird automatisch in den Papierkorb verschoben und nach 30 Tagen gelöscht. Das Zertifikat kann innerhalb der 30 Tage jederzeit wiederhergestellt werden. Falls Sie hier abbrechen, können Sie die Aktualisierung jederzeit in Ihrer Zertifikatsübersicht anfordern. + Zusätzlich übermittelte Zertifikate + Folgende Zertifikate werden bei der Erneuerung als Zusatzinformation übermittelt, damit die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufgenommen werden kann. Diese Zertifikate verbleiben unverändert auf Ihrem Gerät. + Zusätzlich übermittelte Zertifikate + + Stellen Sie bitte bei der Erneuerung von Zertifikaten von Familienmitgliedern sicher, dass die betreffende Person einverstanden ist. + + In bestimmten Fällen werden zusätzlich zu dem zu erneuernden Zertifikat weitere Zertifikate übermittelt. Dies ist erforderlich, um die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufnehmen zu können. \ No newline at end of file diff --git a/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml b/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml index 4fbb17e6c76..51f6175ae8e 100644 --- a/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml +++ b/Corona-Warn-App/src/main/res/values/dcc_reissuance_strings.xml @@ -29,7 +29,14 @@ "The old certificate will be moved automatically to the recycle bin and deleted after 30 days. The certificate can be restored at any time within these 30 days." "If you cancel now, you can request an update in the certificate overview at any time." + Zusätzlich übermittelte Zertifikate + Folgende Zertifikate werden bei der Erneuerung als Zusatzinformation übermittelt, damit die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufgenommen werden kann. Diese Zertifikate verbleiben unverändert auf Ihrem Gerät. + Zusätzlich übermittelte Zertifikate + + Stellen Sie bitte bei der Erneuerung von Zertifikaten von Familienmitgliedern sicher, dass die betreffende Person einverstanden ist. + + In bestimmten Fällen werden zusätzlich zu dem zu erneuernden Zertifikat weitere Zertifikate übermittelt. Dies ist erforderlich, um die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufnehmen zu können. \ No newline at end of file From bf56419d516cfdd8f330af68341311414e17da13 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 07:49:21 +0200 Subject: [PATCH 05/16] fix test --- .../ui/consent/DccReissuanceConsentViewModelTest.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt index 3a392fc6f53..abb72a42f52 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt @@ -81,13 +81,14 @@ internal class DccReissuanceConsentViewModelTest : BaseTest() { @Test fun `getState works`() { viewModel().stateLiveData.getOrAwaitValue() shouldBe DccReissuanceConsentViewModel.State( - certificateList = mutableListOf(), + certificateList = emptyList(), divisionVisible = true, listItemsTitle = "", title = "Zertifikat ersetzen", subtitle = "", content = "Langer Text", - url = "https://www.coronawarn.app/en/faq/#dcc_admission_state" + url = "https://www.coronawarn.app/en/faq/#dcc_admission_state", + accompanyingCertificatesVisible = true ) } From ec46fbb940d474fb0727f60a5a4a6f79548aa769 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 08:02:11 +0200 Subject: [PATCH 06/16] fix test --- .../ui/consent/DccReissuanceConsentViewModelTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt index abb72a42f52..b2a6ecab2c7 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt @@ -88,7 +88,7 @@ internal class DccReissuanceConsentViewModelTest : BaseTest() { subtitle = "", content = "Langer Text", url = "https://www.coronawarn.app/en/faq/#dcc_admission_state", - accompanyingCertificatesVisible = true + accompanyingCertificatesVisible = false ) } From 5994ef3dc274463da9cb4b6dc9c45c8f602a25e1 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 09:40:46 +0200 Subject: [PATCH 07/16] fix test consolidate acc certificates --- .../DccReissuanceConsentFragmentTest.kt | 1 + .../model/DccWalletInfoOutput.kt | 11 ++++++++++ .../consent/DccReissuanceConsentViewModel.kt | 22 +++++++++---------- .../DccReissuanceAccCertsViewModel.kt | 8 +++---- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt index 0e211eae5dc..ff507c78862 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt @@ -91,6 +91,7 @@ class DccReissuanceConsentFragmentTest : BaseUITest() { subtitle = "Neuausstellung direkt über die App vornehmen.", content = "Die Spezifikationen der EU für Zertifikate von Auffrischimpfungen wurden geändert. Dieses Zertifikat entspricht nicht den aktuellen Spezifikationen. Das Impfzertifikat ist zwar weiterhin gültig, es kann jedoch sein, dass bei einer Prüfung die Auffrischimpfung nicht erkannt wird. Bitte lassen Sie sich daher ein neues Impfzertifikat ausstellen.\n\nSie können ein neues Impfzertifikat direkt kostenlos über die App anfordern. Hierfür ist Ihr Einverständnis erforderlich.", url = null, + accompanyingCertificatesVisible = true ) @Before diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt index 1f68d5d4c0e..ef7261b6339 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt @@ -292,6 +292,17 @@ data class CertificateReissuance( certificates = consolidatedCertificates ) } + + fun getConsolidatedAccompanyingCertificates(): Set { + val certsToReissue = certificates.orEmpty().map { + it.certificateToReissue + } + return certificates.orEmpty().flatMap { + it.accompanyingCertificates + }.toMutableSet().apply { + removeAll(certsToReissue) + } + } } data class CertificateReissuanceItem( diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt index 2cfa6761b42..37d7c072b3e 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt @@ -36,7 +36,7 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( private val reissuanceData = personCertificatesProvider.findPersonByIdentifierCode(personIdentifierCode) .map { person -> person?.personIdentifier?.let { personCertificatesSettings.dismissReissuanceBadge(it) } - person?.dccWalletInfo?.certificateReissuance + person?.dccWalletInfo?.certificateReissuance?.migrateLegacyCertificate() } internal val stateLiveData: LiveData = reissuanceData.map { // Make sure DccReissuance exists, otherwise screen is dismissed @@ -61,8 +61,8 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( fun navigateBack() = event.postValue(Back) - private suspend fun CertificateReissuance?.toState(): State { - val certificates = this?.certificates?.mapNotNull { dccCertificate -> + private suspend fun CertificateReissuance.toState(): State { + val certificates = certificates?.mapNotNull { dccCertificate -> try { dccQrCodeExtractor.extract( dccCertificate.certificateToReissue.certificateRef.barcodeData, @@ -78,19 +78,17 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( } } - val accompanyingCertificatesVisible = this?.certificates?.any { - it.accompanyingCertificates.isNotEmpty() - } ?: false + val accompanyingCertificatesVisible = getConsolidatedAccompanyingCertificates().isNotEmpty() return State( certificateList = certificates ?: emptyList(), accompanyingCertificatesVisible = accompanyingCertificatesVisible, - divisionVisible = this?.reissuanceDivision?.visible ?: false, - listItemsTitle = format(this?.reissuanceDivision?.listTitleText), - title = format(this?.reissuanceDivision?.titleText), - subtitle = format(this?.reissuanceDivision?.consentSubtitleText), - content = format(this?.reissuanceDivision?.longText), - url = format(this?.reissuanceDivision?.faqAnchor) + divisionVisible = reissuanceDivision.visible, + listItemsTitle = format(reissuanceDivision.listTitleText), + title = format(reissuanceDivision.titleText), + subtitle = format(reissuanceDivision.consentSubtitleText), + content = format(reissuanceDivision.longText), + url = format(reissuanceDivision.faqAnchor) ) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt index 710478c32d5..774cbf2a73c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -32,17 +32,15 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( private val reissuanceData = personCertificatesProvider.findPersonByIdentifierCode(personIdentifierCode) .map { person -> person?.personIdentifier?.let { personCertificatesSettings.dismissReissuanceBadge(it) } - person?.dccWalletInfo?.certificateReissuance + person?.dccWalletInfo?.certificateReissuance?.migrateLegacyCertificate() } internal val certificatesLiveData: LiveData> = reissuanceData.map { it?.toList() ?: emptyList() }.asLiveData2() - private suspend fun CertificateReissuance?.toList(): List { - return (this?.certificates ?: emptyList()).flatMap { - it.accompanyingCertificates - }.toSet().mapNotNull { + private suspend fun CertificateReissuance.toList(): List { + return getConsolidatedAccompanyingCertificates().mapNotNull { try { dccQrCodeExtractor.extract( it.certificateRef.barcodeData, From 767d88fa0cc8e7f993799c2eb217af90943e9538 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 10:09:11 +0200 Subject: [PATCH 08/16] rename --- .../ccl/dccwalletinfo/model/DccWalletInfoOutput.kt | 2 +- .../dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt | 2 +- .../ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt index ef7261b6339..fc23986c7e1 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoOutput.kt @@ -293,7 +293,7 @@ data class CertificateReissuance( ) } - fun getConsolidatedAccompanyingCertificates(): Set { + fun consolidateAccompanyingCertificates(): Set { val certsToReissue = certificates.orEmpty().map { it.certificateToReissue } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt index 37d7c072b3e..d4e835b9859 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt @@ -78,7 +78,7 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( } } - val accompanyingCertificatesVisible = getConsolidatedAccompanyingCertificates().isNotEmpty() + val accompanyingCertificatesVisible = consolidateAccompanyingCertificates().isNotEmpty() return State( certificateList = certificates ?: emptyList(), diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt index 774cbf2a73c..4f7a13d0058 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -40,7 +40,7 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( }.asLiveData2() private suspend fun CertificateReissuance.toList(): List { - return getConsolidatedAccompanyingCertificates().mapNotNull { + return consolidateAccompanyingCertificates().mapNotNull { try { dccQrCodeExtractor.extract( it.certificateRef.barcodeData, From 48ea41cba0f88e70de1ce5f74d6c08a40bdfbe98 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 14:17:49 +0200 Subject: [PATCH 09/16] view model test --- .../DccReissuanceAccCertsViewModel.kt | 37 ++++---- .../dccwalletinfo/model/DccWalletInfoData.kt | 17 ++-- .../DccReissuanceConsentViewModelTest.kt | 5 +- .../DccReissuanceAccCertsViewModelTest.kt | 84 +++++++++++++++++++ ...cc_wallet_info_output_with_reissuance.json | 2 +- ...et_info_output_with_reissuance_legacy.json | 2 +- 6 files changed, 117 insertions(+), 30 deletions(-) create mode 100644 Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt index 4f7a13d0058..cc3e03515cf 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -1,5 +1,6 @@ package de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts +import androidx.annotation.VisibleForTesting import androidx.lifecycle.LiveData import dagger.assisted.Assisted import dagger.assisted.AssistedFactory @@ -7,8 +8,8 @@ import dagger.assisted.AssistedInject import de.rki.coronawarnapp.ccl.dccwalletinfo.model.CertificateReissuance import de.rki.coronawarnapp.covidcertificate.common.certificate.DccQrCodeExtractor import de.rki.coronawarnapp.covidcertificate.common.certificate.DccV1Parser +import de.rki.coronawarnapp.covidcertificate.common.qrcode.DccQrCode import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesProvider -import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesSettings import de.rki.coronawarnapp.covidcertificate.recovery.core.qrcode.RecoveryCertificateQRCode import de.rki.coronawarnapp.covidcertificate.test.core.qrcode.TestCertificateQRCode import de.rki.coronawarnapp.covidcertificate.vaccination.core.qrcode.VaccinationCertificateQRCode @@ -26,20 +27,15 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( personCertificatesProvider: PersonCertificatesProvider, @Assisted private val personIdentifierCode: String, private val dccQrCodeExtractor: DccQrCodeExtractor, - private val personCertificatesSettings: PersonCertificatesSettings, ) : CWAViewModel(dispatcherProvider) { - private val reissuanceData = personCertificatesProvider.findPersonByIdentifierCode(personIdentifierCode) + internal val certificatesLiveData: LiveData> = personCertificatesProvider + .findPersonByIdentifierCode(personIdentifierCode) .map { person -> - person?.personIdentifier?.let { personCertificatesSettings.dismissReissuanceBadge(it) } - person?.dccWalletInfo?.certificateReissuance?.migrateLegacyCertificate() - } - - internal val certificatesLiveData: LiveData> = reissuanceData.map { - it?.toList() ?: emptyList() - }.asLiveData2() + person?.dccWalletInfo?.certificateReissuance?.migrateLegacyCertificate()?.toItemList().orEmpty() + }.asLiveData2() - private suspend fun CertificateReissuance.toList(): List { + private suspend fun CertificateReissuance.toItemList(): List { return consolidateAccompanyingCertificates().mapNotNull { try { dccQrCodeExtractor.extract( @@ -50,14 +46,7 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( Timber.e(e, "Failed to extract certificate") null } - }.sortedByDescending { - when (it) { - is TestCertificateQRCode -> it.data.certificate.test.sampleCollectedAt?.toLocalDateUserTz() - is VaccinationCertificateQRCode -> it.data.certificate.vaccination.vaccinatedOn - is RecoveryCertificateQRCode -> it.data.certificate.recovery.testedPositiveOn - else -> null - } - }.map { + }.sort().map { DccReissuanceConsentCard.Item(it.data.certificate) } } @@ -69,3 +58,13 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( ): DccReissuanceAccCertsViewModel } } + +@VisibleForTesting +internal fun List.sort() = sortedByDescending { + when (it) { + is TestCertificateQRCode -> it.data.certificate.test.sampleCollectedAt?.toLocalDateUserTz() + is VaccinationCertificateQRCode -> it.data.certificate.vaccination.vaccinatedOn + is RecoveryCertificateQRCode -> it.data.certificate.recovery.testedPositiveOn + else -> null + } +} diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt index 5eeac5b9c6b..33742e13f5f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt @@ -2,6 +2,9 @@ package de.rki.coronawarnapp.ccl.dccwalletinfo.model +val qrCodeStringVac = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" +val qrCodeStringTest = "HC1:6BFOXN*TS0BI\$ZDFRH7LHUVNU.8GZ6769MBW3XHP+56R5LLPJ*5PIM*V4DZJIRPQHIZC4.OI:OIG/Q*LP1Z2GHKW/F3IKJ5QH*AF/GJ5MT0K5LO$50D$0SVV88UI*488UZ+3H0LW6WD1KG8U%8W+*3Y:CYZ00OPM98IMIWLHWVHPYH9UE*P1UU1XF820Q R1D.L%:PVLIJRH.OG4SIIRH/R2UZUWM6J$7XLH5G6TH95NI.J2IQ1TU1/PIMJEWT4SS3+Y3D.R9\$H.I8HX7B%R J8VR7* FLVKDN4FTITQI.:KO3HWBJ\$IJQFGSW5B*5:3AUM9NK9:AA945MR9EG3XFJ0%SI23D-I/2DBAJDAJCNB-43 X41Q2EG3RA3/43KD3F23.+IIYC6Q0ZIJPKJ+LJ5AL5:4A93VLJOPG32NQ3QR\$P*NIV1JK%228K*IBYZJ92KENS+7K*8BCIIM7JC0J3LIH.SO4UBR2:ZJ83B4PSZEUP637PS36JF0JEYI1DLZZL1629HQ-A6G 713JIZA213DY4F M52Q0VP25A75Q6TMR V$6L LOOUOPDVSQQR/TTJM:R7:SF90T99K4BTET0J/K%EN6 7I-DRK6*0L03SI30NVB-3" + private val boosterNotification = BoosterNotification( visible = true, titleText = SingleText( @@ -25,7 +28,7 @@ private val boosterNotification = BoosterNotification( private val mostRelevantCertificate = Certificate( certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" + barcodeData = qrCodeStringVac ) ) @@ -38,7 +41,7 @@ private val verification = Verification( parameters = listOf() ), certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" + barcodeData = qrCodeStringVac ) ), @@ -49,7 +52,7 @@ private val verification = Verification( parameters = listOf() ), certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDFRH7LHUVNU.8GZ6769MBW3XHP+56R5LLPJ*5PIM*V4DZJIRPQHIZC4.OI:OIG/Q*LP1Z2GHKW/F3IKJ5QH*AF/GJ5MT0K5LO$50D$0SVV88UI*488UZ+3H0LW6WD1KG8U%8W+*3Y:CYZ00OPM98IMIWLHWVHPYH9UE*P1UU1XF820Q R1D.L%:PVLIJRH.OG4SIIRH/R2UZUWM6J$7XLH5G6TH95NI.J2IQ1TU1/PIMJEWT4SS3+Y3D.R9\$H.I8HX7B%R J8VR7* FLVKDN4FTITQI.:KO3HWBJ\$IJQFGSW5B*5:3AUM9NK9:AA945MR9EG3XFJ0%SI23D-I/2DBAJDAJCNB-43 X41Q2EG3RA3/43KD3F23.+IIYC6Q0ZIJPKJ+LJ5AL5:4A93VLJOPG32NQ3QR\$P*NIV1JK%228K*IBYZJ92KENS+7K*8BCIIM7JC0J3LIH.SO4UBR2:ZJ83B4PSZEUP637PS36JF0JEYI1DLZZL1629HQ-A6G 713JIZA213DY4F M52Q0VP25A75Q6TMR V$6L LOOUOPDVSQQR/TTJM:R7:SF90T99K4BTET0J/K%EN6 7I-DRK6*0L03SI30NVB-3" + barcodeData = qrCodeStringTest ) ) ) @@ -152,13 +155,13 @@ private val certificateReissuanceLegacy = CertificateReissuance( ), certificateToReissue = Certificate( certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0", + barcodeData = qrCodeStringVac, ) ), accompanyingCertificates = listOf( Certificate( certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" + barcodeData = qrCodeStringTest ) ) ) @@ -199,13 +202,13 @@ private val certificateReissuance = CertificateReissuance( CertificateReissuanceItem( certificateToReissue = Certificate( certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0", + barcodeData = qrCodeStringVac, ) ), accompanyingCertificates = listOf( Certificate( certificateRef = CertificateRef( - barcodeData = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" + barcodeData = qrCodeStringTest ) ) ), diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt index b2a6ecab2c7..e5bc75bffff 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt @@ -76,19 +76,20 @@ internal class DccReissuanceConsentViewModelTest : BaseTest() { } } coEvery { personCertificatesSettings.dismissReissuanceBadge(any()) } just Runs + every { metadata.personIdentifier } returns identifier } @Test fun `getState works`() { viewModel().stateLiveData.getOrAwaitValue() shouldBe DccReissuanceConsentViewModel.State( - certificateList = emptyList(), + certificateList = listOf(DccReissuanceConsentCard.Item(metadata)), divisionVisible = true, listItemsTitle = "", title = "Zertifikat ersetzen", subtitle = "", content = "Langer Text", url = "https://www.coronawarn.app/en/faq/#dcc_admission_state", - accompanyingCertificatesVisible = false + accompanyingCertificatesVisible = true ) } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt new file mode 100644 index 00000000000..c6bea16b04e --- /dev/null +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt @@ -0,0 +1,84 @@ +package de.rki.coronawarnapp.dccreissuance.ui.consent.acccert + +import de.rki.coronawarnapp.ccl.dccwalletinfo.model.dccWalletInfoWithReissuance +import de.rki.coronawarnapp.covidcertificate.common.certificate.CertificatePersonIdentifier +import de.rki.coronawarnapp.covidcertificate.common.certificate.CwaCovidCertificate +import de.rki.coronawarnapp.covidcertificate.common.certificate.DccData +import de.rki.coronawarnapp.covidcertificate.common.certificate.DccQrCodeExtractor +import de.rki.coronawarnapp.covidcertificate.common.certificate.DccV1 +import de.rki.coronawarnapp.covidcertificate.common.qrcode.DccQrCode +import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificates +import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesProvider +import de.rki.coronawarnapp.covidcertificate.vaccination.core.VaccinationCertificate +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentCard +import de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts.DccReissuanceAccCertsViewModel +import io.kotest.matchers.shouldBe +import io.mockk.MockKAnnotations +import io.mockk.coEvery +import io.mockk.every +import io.mockk.impl.annotations.MockK +import io.mockk.mockk +import kotlinx.coroutines.flow.flowOf +import org.joda.time.LocalDate +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import testhelpers.BaseTest +import testhelpers.TestDispatcherProvider +import testhelpers.extensions.InstantExecutorExtension +import testhelpers.extensions.getOrAwaitValue + +@ExtendWith(InstantExecutorExtension::class) +internal class DccReissuanceAccCertsViewModelTest : BaseTest() { + + @MockK lateinit var personCertificatesProvider: PersonCertificatesProvider + @MockK lateinit var dccQrCodeExtractor: DccQrCodeExtractor + @MockK lateinit var dccQrCode: DccQrCode + @MockK lateinit var metadata: DccV1.MetaData + @MockK lateinit var cwaCertificates: CwaCovidCertificate + + private val identifier = CertificatePersonIdentifier( + dateOfBirthFormatted = "01.10.1982", + firstNameStandardized = "fN", + lastNameStandardized = "lN" + ) + + private val vaccinationCertificate = mockk().apply { + every { personIdentifier } returns identifier + every { vaccinatedOn } returns LocalDate.parse("2021-10-03") + } + + @BeforeEach + fun setUp() { + MockKAnnotations.init(this) + every { cwaCertificates.personIdentifier } returns identifier + every { personCertificatesProvider.findPersonByIdentifierCode(any()) } returns flowOf( + PersonCertificates( + certificates = listOf(vaccinationCertificate), + dccWalletInfo = dccWalletInfoWithReissuance + ) + ) + + every { metadata.personIdentifier } returns identifier + + coEvery { dccQrCodeExtractor.extract(any(), any()) } returns dccQrCode.apply { + every { data } returns mockk>().apply { + every { certificate } returns metadata + } + } + } + + @Test + fun `getState works`() { + viewModel().certificatesLiveData.getOrAwaitValue() shouldBe listOf( + DccReissuanceConsentCard.Item(metadata) + ) + } + + private fun viewModel() = DccReissuanceAccCertsViewModel( + dispatcherProvider = TestDispatcherProvider(), + personCertificatesProvider = personCertificatesProvider, + personIdentifierCode = "code", + dccQrCodeExtractor = dccQrCodeExtractor, + ) +} diff --git a/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance.json b/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance.json index 333e7c2d553..6197e544490 100644 --- a/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance.json +++ b/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance.json @@ -190,7 +190,7 @@ "accompanyingCertificates": [ { "certificateRef": { - "barcodeData": "HC1:6BFOXN*TS0BI$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE $CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" + "barcodeData": "HC1:6BFOXN*TS0BI$ZDFRH7LHUVNU.8GZ6769MBW3XHP+56R5LLPJ*5PIM*V4DZJIRPQHIZC4.OI:OIG/Q*LP1Z2GHKW/F3IKJ5QH*AF/GJ5MT0K5LO$50D$0SVV88UI*488UZ+3H0LW6WD1KG8U%8W+*3Y:CYZ00OPM98IMIWLHWVHPYH9UE*P1UU1XF820Q R1D.L%:PVLIJRH.OG4SIIRH/R2UZUWM6J$7XLH5G6TH95NI.J2IQ1TU1/PIMJEWT4SS3+Y3D.R9$H.I8HX7B%R J8VR7* FLVKDN4FTITQI.:KO3HWBJ$IJQFGSW5B*5:3AUM9NK9:AA945MR9EG3XFJ0%SI23D-I/2DBAJDAJCNB-43 X41Q2EG3RA3/43KD3F23.+IIYC6Q0ZIJPKJ+LJ5AL5:4A93VLJOPG32NQ3QR$P*NIV1JK%228K*IBYZJ92KENS+7K*8BCIIM7JC0J3LIH.SO4UBR2:ZJ83B4PSZEUP637PS36JF0JEYI1DLZZL1629HQ-A6G 713JIZA213DY4F M52Q0VP25A75Q6TMR V$6L LOOUOPDVSQQR/TTJM:R7:SF90T99K4BTET0J/K%EN6 7I-DRK6*0L03SI30NVB-3" } } ], diff --git a/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance_legacy.json b/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance_legacy.json index cb9b90ce204..d9355a0bef0 100644 --- a/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance_legacy.json +++ b/Corona-Warn-App/src/test/resources/ccl/dcc_wallet_info_output_with_reissuance_legacy.json @@ -175,7 +175,7 @@ "accompanyingCertificates": [ { "certificateRef": { - "barcodeData": "HC1:6BFOXN*TS0BI$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE $CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" + "barcodeData": "HC1:6BFOXN*TS0BI$ZDFRH7LHUVNU.8GZ6769MBW3XHP+56R5LLPJ*5PIM*V4DZJIRPQHIZC4.OI:OIG/Q*LP1Z2GHKW/F3IKJ5QH*AF/GJ5MT0K5LO$50D$0SVV88UI*488UZ+3H0LW6WD1KG8U%8W+*3Y:CYZ00OPM98IMIWLHWVHPYH9UE*P1UU1XF820Q R1D.L%:PVLIJRH.OG4SIIRH/R2UZUWM6J$7XLH5G6TH95NI.J2IQ1TU1/PIMJEWT4SS3+Y3D.R9$H.I8HX7B%R J8VR7* FLVKDN4FTITQI.:KO3HWBJ$IJQFGSW5B*5:3AUM9NK9:AA945MR9EG3XFJ0%SI23D-I/2DBAJDAJCNB-43 X41Q2EG3RA3/43KD3F23.+IIYC6Q0ZIJPKJ+LJ5AL5:4A93VLJOPG32NQ3QR$P*NIV1JK%228K*IBYZJ92KENS+7K*8BCIIM7JC0J3LIH.SO4UBR2:ZJ83B4PSZEUP637PS36JF0JEYI1DLZZL1629HQ-A6G 713JIZA213DY4F M52Q0VP25A75Q6TMR V$6L LOOUOPDVSQQR/TTJM:R7:SF90T99K4BTET0J/K%EN6 7I-DRK6*0L03SI30NVB-3" } } ] From a2dea66cda626ce5584602aaaedb9ad53ea1ed48 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 14:53:35 +0200 Subject: [PATCH 10/16] fix merge --- .../dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt | 2 +- .../ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt | 2 +- .../ccl/dccwalletinfo/model/DccWalletInfoData.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt index d4e835b9859..8ea218d1f5e 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt @@ -36,7 +36,7 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( private val reissuanceData = personCertificatesProvider.findPersonByIdentifierCode(personIdentifierCode) .map { person -> person?.personIdentifier?.let { personCertificatesSettings.dismissReissuanceBadge(it) } - person?.dccWalletInfo?.certificateReissuance?.migrateLegacyCertificate() + person?.dccWalletInfo?.certificateReissuance?.asCertificateReissuanceCompat() } internal val stateLiveData: LiveData = reissuanceData.map { // Make sure DccReissuance exists, otherwise screen is dismissed diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt index cc3e03515cf..6fcd85c9086 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -32,7 +32,7 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( internal val certificatesLiveData: LiveData> = personCertificatesProvider .findPersonByIdentifierCode(personIdentifierCode) .map { person -> - person?.dccWalletInfo?.certificateReissuance?.migrateLegacyCertificate()?.toItemList().orEmpty() + person?.dccWalletInfo?.certificateReissuance?.asCertificateReissuanceCompat()?.toItemList().orEmpty() }.asLiveData2() private suspend fun CertificateReissuance.toItemList(): List { diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt index 33742e13f5f..53c007036ee 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/DccWalletInfoData.kt @@ -2,8 +2,8 @@ package de.rki.coronawarnapp.ccl.dccwalletinfo.model -val qrCodeStringVac = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" -val qrCodeStringTest = "HC1:6BFOXN*TS0BI\$ZDFRH7LHUVNU.8GZ6769MBW3XHP+56R5LLPJ*5PIM*V4DZJIRPQHIZC4.OI:OIG/Q*LP1Z2GHKW/F3IKJ5QH*AF/GJ5MT0K5LO$50D$0SVV88UI*488UZ+3H0LW6WD1KG8U%8W+*3Y:CYZ00OPM98IMIWLHWVHPYH9UE*P1UU1XF820Q R1D.L%:PVLIJRH.OG4SIIRH/R2UZUWM6J$7XLH5G6TH95NI.J2IQ1TU1/PIMJEWT4SS3+Y3D.R9\$H.I8HX7B%R J8VR7* FLVKDN4FTITQI.:KO3HWBJ\$IJQFGSW5B*5:3AUM9NK9:AA945MR9EG3XFJ0%SI23D-I/2DBAJDAJCNB-43 X41Q2EG3RA3/43KD3F23.+IIYC6Q0ZIJPKJ+LJ5AL5:4A93VLJOPG32NQ3QR\$P*NIV1JK%228K*IBYZJ92KENS+7K*8BCIIM7JC0J3LIH.SO4UBR2:ZJ83B4PSZEUP637PS36JF0JEYI1DLZZL1629HQ-A6G 713JIZA213DY4F M52Q0VP25A75Q6TMR V$6L LOOUOPDVSQQR/TTJM:R7:SF90T99K4BTET0J/K%EN6 7I-DRK6*0L03SI30NVB-3" +const val qrCodeStringVac = "HC1:6BFOXN*TS0BI\$ZDYSHTRMM7QXSUJCQF*8KF6NDC2LE \$CGH9XYE+9GDJ5RPSDW1:ZH6I1$4JN:IN1MPK95%LS+1VUU8C1VTE5ZMT56QHECDVNE1FO1P56C\$QV/M8YML-1H1V*ZE846N07WW667N+H1YU1E 1PK9B/0E7J0PIBZIXJA CG8CGZK*9C%PDS1JGDBVF2$7K*IBQQKV-J2 JDZT:1BPMIMIA*NI7UJQWT.+S1QD4007/GJ2HIE9WT0K3M9UVZSVV*001HW%8UE9.955B9-NT0 2$$0X4PPZ0YUIPG1L+N1*PVD4WYHPRAAUICO1-.PU8GIFT383/9TL4T.B9NVP-PELK9D/5.B9C9Q8+ECB9UH9B/9BL5 QE-NEO+11C9P8Q+C9:6V P1HS9UM97H98\$QP3R8BH FRDRIS4FU2STU14G8R6U1YS+FRH8E0IF*+K1D4QIV9BRZX26 L**T -MEUIM3W1KI-\$BEBIU2B4+QF2HFUHBO3E/01.SW:O44BV7QU00W56:0" +const val qrCodeStringTest = "HC1:6BFOXN*TS0BI\$ZDFRH7LHUVNU.8GZ6769MBW3XHP+56R5LLPJ*5PIM*V4DZJIRPQHIZC4.OI:OIG/Q*LP1Z2GHKW/F3IKJ5QH*AF/GJ5MT0K5LO$50D$0SVV88UI*488UZ+3H0LW6WD1KG8U%8W+*3Y:CYZ00OPM98IMIWLHWVHPYH9UE*P1UU1XF820Q R1D.L%:PVLIJRH.OG4SIIRH/R2UZUWM6J$7XLH5G6TH95NI.J2IQ1TU1/PIMJEWT4SS3+Y3D.R9\$H.I8HX7B%R J8VR7* FLVKDN4FTITQI.:KO3HWBJ\$IJQFGSW5B*5:3AUM9NK9:AA945MR9EG3XFJ0%SI23D-I/2DBAJDAJCNB-43 X41Q2EG3RA3/43KD3F23.+IIYC6Q0ZIJPKJ+LJ5AL5:4A93VLJOPG32NQ3QR\$P*NIV1JK%228K*IBYZJ92KENS+7K*8BCIIM7JC0J3LIH.SO4UBR2:ZJ83B4PSZEUP637PS36JF0JEYI1DLZZL1629HQ-A6G 713JIZA213DY4F M52Q0VP25A75Q6TMR V$6L LOOUOPDVSQQR/TTJM:R7:SF90T99K4BTET0J/K%EN6 7I-DRK6*0L03SI30NVB-3" private val boosterNotification = BoosterNotification( visible = true, From 772fb8a9bbe6e6500f6c54cd28254e406f280579 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Thu, 12 May 2022 15:12:35 +0200 Subject: [PATCH 11/16] sort test --- .../ui/consent/acccert/SortTest.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/SortTest.kt diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/SortTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/SortTest.kt new file mode 100644 index 00000000000..9592ae6a170 --- /dev/null +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/SortTest.kt @@ -0,0 +1,43 @@ +package de.rki.coronawarnapp.dccreissuance.ui.consent.acccert + +import de.rki.coronawarnapp.covidcertificate.recovery.core.qrcode.RecoveryCertificateQRCode +import de.rki.coronawarnapp.covidcertificate.test.core.qrcode.TestCertificateQRCode +import de.rki.coronawarnapp.covidcertificate.vaccination.core.qrcode.VaccinationCertificateQRCode +import de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts.sort +import io.kotest.matchers.shouldBe +import io.mockk.MockKAnnotations +import io.mockk.every +import io.mockk.impl.annotations.MockK +import org.joda.time.Instant +import org.joda.time.LocalDate +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import testhelpers.BaseTest + +class SortTest : BaseTest() { + + @MockK lateinit var vacQrCode: VaccinationCertificateQRCode + @MockK lateinit var recQrCode: RecoveryCertificateQRCode + @MockK lateinit var testQrCode: TestCertificateQRCode + + @BeforeEach + fun setUp() { + MockKAnnotations.init(this) + } + + @Test + fun `sort works`() { + every { vacQrCode.data.certificate.vaccination.vaccinatedOn } returns LocalDate.parse("2022-01-01") + every { recQrCode.data.certificate.recovery.testedPositiveOn } returns LocalDate.parse("2022-01-03") + every { testQrCode.data.certificate.test.sampleCollectedAt } returns Instant.parse("2022-01-05") + listOf(vacQrCode, testQrCode, recQrCode).sort() shouldBe listOf(testQrCode, recQrCode, vacQrCode) + } + + @Test + fun `sort works 2`() { + every { vacQrCode.data.certificate.vaccination.vaccinatedOn } returns LocalDate.parse("2022-02-01") + every { recQrCode.data.certificate.recovery.testedPositiveOn } returns LocalDate.parse("2022-01-03") + every { testQrCode.data.certificate.test.sampleCollectedAt } returns Instant.parse("2022-03-05") + listOf(vacQrCode, testQrCode, recQrCode).sort() shouldBe listOf(testQrCode, vacQrCode, recQrCode) + } +} From 12f3d8f193b2894589e49f7371fa5d1da14f0b9c Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Mon, 16 May 2022 12:33:21 +0200 Subject: [PATCH 12/16] ui test --- .../DccReissuanceConsentFragmentTest.kt | 4 +- .../DccReissuanceAccCertsFragmentTest.kt | 125 ++++++++++++++++++ .../FragmentTestModuleRegistrar.kt | 2 + .../ui/consent/DccReissuanceAdapter.kt | 2 +- ...ard.kt => DccReissuanceCertificateCard.kt} | 4 +- .../consent/DccReissuanceConsentViewModel.kt | 2 +- .../DccReissuanceAccCertsViewModel.kt | 6 +- .../DccReissuanceConsentViewModelTest.kt | 2 +- .../DccReissuanceAccCertsViewModelTest.kt | 4 +- 9 files changed, 139 insertions(+), 12 deletions(-) create mode 100644 Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt rename Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/{DccReissuanceConsentCard.kt => DccReissuanceCertificateCard.kt} (96%) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt index ff507c78862..3fff7acf694 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragmentTest.kt @@ -48,7 +48,7 @@ class DccReissuanceConsentFragmentTest : BaseUITest() { private val state = DccReissuanceConsentViewModel.State( certificateList = mutableListOf( - DccReissuanceConsentCard.Item( + DccReissuanceCertificateCard.Item( mockk { every { nameData } returns mockk { every { fullName } returns "Andrea Schneider" @@ -66,7 +66,7 @@ class DccReissuanceConsentFragmentTest : BaseUITest() { } } ), - DccReissuanceConsentCard.Item( + DccReissuanceCertificateCard.Item( mockk { every { nameData } returns mockk { every { fullName } returns "Andrea Schneider" diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt new file mode 100644 index 00000000000..cffd5fda6ce --- /dev/null +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt @@ -0,0 +1,125 @@ +package de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts + +import androidx.lifecycle.ViewModelStore +import androidx.lifecycle.liveData +import androidx.navigation.testing.TestNavHostController +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.internal.runner.junit4.statement.UiThreadStatement +import dagger.Module +import dagger.android.ContributesAndroidInjector +import de.rki.coronawarnapp.R +import de.rki.coronawarnapp.covidcertificate.common.certificate.CertificatePersonIdentifier +import de.rki.coronawarnapp.covidcertificate.common.certificate.VaccinationDccV1 +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceCertificateCard +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceItem +import io.mockk.MockKAnnotations +import io.mockk.every +import io.mockk.impl.annotations.RelaxedMockK +import io.mockk.mockk +import org.joda.time.LocalDate +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import testhelpers.BaseUITest +import testhelpers.Screenshot +import testhelpers.launchFragment2 +import testhelpers.launchFragmentInContainer2 +import testhelpers.takeScreenshot + +@RunWith(AndroidJUnit4::class) +class DccReissuanceAccCertsFragmentTest : BaseUITest() { + + @RelaxedMockK lateinit var viewModel: DccReissuanceAccCertsViewModel + + private val navController = TestNavHostController( + context = ApplicationProvider.getApplicationContext() + ).apply { + UiThreadStatement.runOnUiThread { + setViewModelStore(ViewModelStore()) + setGraph(R.navigation.covid_certificates_graph) + setCurrentDestination(R.id.dccReissuanceAccCertsFragment) + } + } + + private val args = DccReissuanceAccCertsFragmentArgs(personIdentifierCode = "personIdentifierCode").toBundle() + + private val certificateList = mutableListOf( + DccReissuanceCertificateCard.Item( + mockk { + every { nameData } returns mockk { + every { fullName } returns "Andrea Schneider" + } + + every { vaccination } returns mockk { + every { doseNumber } returns 2 + every { totalSeriesOfDoses } returns 2 + every { vaccinatedOn } returns LocalDate.parse("2022-01-15") + every { personIdentifier } returns CertificatePersonIdentifier( + dateOfBirthFormatted = "1980-06-01", + lastNameStandardized = "Schneider", + firstNameStandardized = "Andrea" + ) + } + } + ), + DccReissuanceCertificateCard.Item( + mockk { + every { nameData } returns mockk { + every { fullName } returns "Andrea Schneider" + } + + every { vaccination } returns mockk { + every { doseNumber } returns 1 + every { totalSeriesOfDoses } returns 2 + every { vaccinatedOn } returns LocalDate.parse("2021-10-17") + every { personIdentifier } returns CertificatePersonIdentifier( + dateOfBirthFormatted = "1980-06-01", + lastNameStandardized = "Schneider", + firstNameStandardized = "Andrea" + ) + } + } + ) + ) + + @Before + fun setup() { + MockKAnnotations.init(this) + + every { viewModel.certificatesLiveData } returns liveData { emit(certificateList) } + + setupMockViewModel( + factory = object : DccReissuanceAccCertsViewModel.Factory { + override fun create(personIdentifierCode: String): DccReissuanceAccCertsViewModel = viewModel + } + ) + } + + @After + fun tearDown() { + clearAllViewModels() + } + + @Test + fun launch_fragment() { + launchFragment2(fragmentArgs = args) + } + + @Test + @Screenshot + fun capture_fragment() { + launchFragmentInContainer2( + testNavHostController = navController, + fragmentArgs = args + ) + takeScreenshot("1") + } +} + +@Module +abstract class DccReissuanceAccCertsFragmentTestModule { + @ContributesAndroidInjector + abstract fun dccReissuanceAccCertsFragment(): DccReissuanceAccCertsFragment +} diff --git a/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt b/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt index 9c485cd983a..c0e6c5af10a 100644 --- a/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt +++ b/Corona-Warn-App/src/androidTest/java/testhelpers/FragmentTestModuleRegistrar.kt @@ -12,6 +12,7 @@ import de.rki.coronawarnapp.covidcertificate.recovery.ui.RecoveryCertificateDeta import de.rki.coronawarnapp.covidcertificate.test.ui.CovidCertificateDetailsFragmentTestModule import de.rki.coronawarnapp.covidcertificate.vaccination.ui.details.VaccinationDetailsFragmentTestModule import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentFragmentTestModule +import de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts.DccReissuanceAccCertsFragmentTestModule import de.rki.coronawarnapp.dccticketing.ui.certificateselection.DccTicketingCertificateSelectionFragmentModule import de.rki.coronawarnapp.dccticketing.ui.consent.one.DccTicketingConsentOneFragmentTestModule import de.rki.coronawarnapp.dccticketing.ui.consent.two.DccTicketingConsentTwoFragmentModule @@ -133,6 +134,7 @@ import kotlinx.coroutines.test.TestScope PersonDetailsFragmentTestModule::class, BoosterInfoDetailsFragmentTestModule::class, DccReissuanceConsentFragmentTestModule::class, + DccReissuanceAccCertsFragmentTestModule::class, // -------- Profile ------------ ProfileCreateFragmentTestModule::class, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt index b8024780f1a..57c1d8df05a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt @@ -23,7 +23,7 @@ class DccReissuanceAdapter : listOf( StableIdMod(data), DataBinderMod>(data), - TypedVHCreatorMod({ data[it] is DccReissuanceConsentCard.Item }) { DccReissuanceConsentCard(it) } + TypedVHCreatorMod({ data[it] is DccReissuanceCertificateCard.Item }) { DccReissuanceCertificateCard(it) } ) ) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentCard.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceCertificateCard.kt similarity index 96% rename from Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentCard.kt rename to Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceCertificateCard.kt index 75d910563c7..83909080e95 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentCard.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceCertificateCard.kt @@ -12,8 +12,8 @@ import de.rki.coronawarnapp.util.TimeAndDateExtensions.toShortDayFormat import de.rki.coronawarnapp.util.TimeAndDateExtensions.toUserTimeZone import de.rki.coronawarnapp.util.lists.diffutil.HasPayloadDiffer -class DccReissuanceConsentCard(parent: ViewGroup) : - DccReissuanceAdapter.ItemVH( +class DccReissuanceCertificateCard(parent: ViewGroup) : + DccReissuanceAdapter.ItemVH( layoutRes = R.layout.dcc_reissuance_certificate_card, parent = parent ) { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt index 8ea218d1f5e..438d5f98713 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModel.kt @@ -68,7 +68,7 @@ class DccReissuanceConsentViewModel @AssistedInject constructor( dccCertificate.certificateToReissue.certificateRef.barcodeData, DccV1Parser.Mode.CERT_SINGLE_STRICT ).data.certificate.let { - DccReissuanceConsentCard.Item( + DccReissuanceCertificateCard.Item( it ) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt index 6fcd85c9086..2d099fe024a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsViewModel.kt @@ -13,7 +13,7 @@ import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesProvi import de.rki.coronawarnapp.covidcertificate.recovery.core.qrcode.RecoveryCertificateQRCode import de.rki.coronawarnapp.covidcertificate.test.core.qrcode.TestCertificateQRCode import de.rki.coronawarnapp.covidcertificate.vaccination.core.qrcode.VaccinationCertificateQRCode -import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentCard +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceCertificateCard import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceItem import de.rki.coronawarnapp.util.TimeAndDateExtensions.toLocalDateUserTz import de.rki.coronawarnapp.util.coroutine.DispatcherProvider @@ -47,7 +47,7 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( null } }.sort().map { - DccReissuanceConsentCard.Item(it.data.certificate) + DccReissuanceCertificateCard.Item(it.data.certificate) } } @@ -62,9 +62,9 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor( @VisibleForTesting internal fun List.sort() = sortedByDescending { when (it) { - is TestCertificateQRCode -> it.data.certificate.test.sampleCollectedAt?.toLocalDateUserTz() is VaccinationCertificateQRCode -> it.data.certificate.vaccination.vaccinatedOn is RecoveryCertificateQRCode -> it.data.certificate.recovery.testedPositiveOn + is TestCertificateQRCode -> it.data.certificate.test.sampleCollectedAt?.toLocalDateUserTz() else -> null } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt index e5bc75bffff..e99931c6c4e 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentViewModelTest.kt @@ -82,7 +82,7 @@ internal class DccReissuanceConsentViewModelTest : BaseTest() { @Test fun `getState works`() { viewModel().stateLiveData.getOrAwaitValue() shouldBe DccReissuanceConsentViewModel.State( - certificateList = listOf(DccReissuanceConsentCard.Item(metadata)), + certificateList = listOf(DccReissuanceCertificateCard.Item(metadata)), divisionVisible = true, listItemsTitle = "", title = "Zertifikat ersetzen", diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt index c6bea16b04e..be2097dd3fa 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccert/DccReissuanceAccCertsViewModelTest.kt @@ -10,7 +10,7 @@ import de.rki.coronawarnapp.covidcertificate.common.qrcode.DccQrCode import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificates import de.rki.coronawarnapp.covidcertificate.person.core.PersonCertificatesProvider import de.rki.coronawarnapp.covidcertificate.vaccination.core.VaccinationCertificate -import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceConsentCard +import de.rki.coronawarnapp.dccreissuance.ui.consent.DccReissuanceCertificateCard import de.rki.coronawarnapp.dccreissuance.ui.consent.acccerts.DccReissuanceAccCertsViewModel import io.kotest.matchers.shouldBe import io.mockk.MockKAnnotations @@ -71,7 +71,7 @@ internal class DccReissuanceAccCertsViewModelTest : BaseTest() { @Test fun `getState works`() { viewModel().certificatesLiveData.getOrAwaitValue() shouldBe listOf( - DccReissuanceConsentCard.Item(metadata) + DccReissuanceCertificateCard.Item(metadata) ) } From 75527472bdaa30b5a8b239f5b39813ef498cbb40 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Mon, 16 May 2022 13:02:37 +0200 Subject: [PATCH 13/16] move adapter declaration --- .../dccreissuance/ui/consent/DccReissuanceConsentFragment.kt | 4 ++-- .../ui/consent/acccerts/DccReissuanceAccCertsFragment.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt index 7cc24479655..b9a1fd15b2b 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceConsentFragment.kt @@ -35,8 +35,6 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c } ) - private val dccReissuanceAdapter = DccReissuanceAdapter() - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -47,6 +45,8 @@ class DccReissuanceConsentFragment : Fragment(R.layout.fragment_dcc_reissuance_c override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + val dccReissuanceAdapter = DccReissuanceAdapter() + binding.apply { toolbar.setNavigationOnClickListener { viewModel.navigateBack() } cancelButton.setOnClickListener { viewModel.navigateBack() } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt index e93512b0e6c..3d2169b837c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragment.kt @@ -32,8 +32,6 @@ class DccReissuanceAccCertsFragment : Fragment(R.layout.fragment_dcc_reissuance_ } ) - private val dccReissuanceAdapter = DccReissuanceAdapter() - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -44,6 +42,8 @@ class DccReissuanceAccCertsFragment : Fragment(R.layout.fragment_dcc_reissuance_ override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + val dccReissuanceAdapter = DccReissuanceAdapter() + binding.apply { toolbar.setNavigationOnClickListener { popBackStack() } From 6b0abdc14a3be58578de41f3831e510f61ffa6b4 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 16 May 2022 14:47:14 +0200 Subject: [PATCH 14/16] Update Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml Co-authored-by: KathrinLuecke <91470863+KathrinLuecke@users.noreply.github.com> --- .../src/main/res/values-de/dcc_reissuance_strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml b/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml index 53596ba97b6..0438773f52d 100644 --- a/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml +++ b/Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml @@ -35,7 +35,7 @@ Zusätzlich übermittelte Zertifikate - Folgende Zertifikate werden bei der Erneuerung als Zusatzinformation übermittelt, damit die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufgenommen werden kann. Diese Zertifikate verbleiben unverändert auf Ihrem Gerät. + Folgende Zertifikate werden bei der Erneuerung als Zusatzinformation übermittelt, damit die bisherige Abfolge der Impfungen und Genesungen im neuen Zertifikat aufgenommen werden kann. Diese Zertifikate werden nicht erneuert. Zusätzlich übermittelte Zertifikate From a3db9a2f31af250f0d86b8855bbdfd10e5844269 Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Mon, 16 May 2022 16:15:05 +0200 Subject: [PATCH 15/16] unit test --- .../CertificateReissuanceExtensionTest.kt | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt new file mode 100644 index 00000000000..fec2b25e8dc --- /dev/null +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt @@ -0,0 +1,162 @@ +package de.rki.coronawarnapp.ccl.dccwalletinfo.model + +import io.kotest.matchers.collections.shouldContainAll +import io.kotest.matchers.shouldBe +import io.mockk.mockk +import org.junit.jupiter.api.Test +import testhelpers.BaseTest + +internal class CertificateReissuanceExtensionTest : BaseTest() { + + val reissuanceDivision: ReissuanceDivision = mockk() + + private val certificateReissuanceLegacy = CertificateReissuance( + reissuanceDivision = reissuanceDivision, + certificateToReissue = Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringVac, + ) + ), + accompanyingCertificates = listOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ) + ) + + private val certificateReissuance = CertificateReissuance( + reissuanceDivision = reissuanceDivision, + certificates = listOf( + CertificateReissuanceItem( + certificateToReissue = Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringVac, + ) + ), + accompanyingCertificates = listOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ), + action = "renew" + ), + ) + ) + + private val certificateReissuance2 = CertificateReissuance( + reissuanceDivision = mockk(), + certificates = listOf( + CertificateReissuanceItem( + certificateToReissue = Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringVac, + ) + ), + accompanyingCertificates = listOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ), + action = "renew" + ), + CertificateReissuanceItem( + certificateToReissue = Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest, + ) + ), + accompanyingCertificates = listOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringVac + ) + ) + ), + action = "extend" + ), + ) + ) + + private val certificateReissuance3 = CertificateReissuance( + reissuanceDivision = mockk(), + certificates = listOf( + CertificateReissuanceItem( + certificateToReissue = Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringVac, + ) + ), + accompanyingCertificates = listOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ), + action = "renew" + ), + CertificateReissuanceItem( + certificateToReissue = Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringVac, + ) + ), + accompanyingCertificates = listOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ), + action = "extend" + ), + ) + ) + + @Test + fun `compat test`() { + certificateReissuanceLegacy.asCertificateReissuanceCompat() shouldBe + certificateReissuance + } + + @Test + fun `certificate consolidation test`() { + val set = certificateReissuance.consolidateAccompanyingCertificates() + set shouldContainAll + setOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ) + set.size shouldBe 1 + } + + @Test + fun `certificate consolidation test with certificates which accompany each other`() { + val set = certificateReissuance2.consolidateAccompanyingCertificates() + set.size shouldBe 0 + } + + @Test + fun `certificate consolidation test with duplicates`() { + val set = certificateReissuance3.consolidateAccompanyingCertificates() + set shouldContainAll + setOf( + Certificate( + certificateRef = CertificateRef( + barcodeData = qrCodeStringTest + ) + ) + ) + set.size shouldBe 1 + } + +} From c90b96e16f2a9bc15ecf33d1122ec5e57e87962e Mon Sep 17 00:00:00 2001 From: Chilja Gossow <49635654+chiljamgossow@users.noreply.github.com> Date: Mon, 16 May 2022 16:52:28 +0200 Subject: [PATCH 16/16] klint --- .../DccReissuanceAccCertsFragmentTest.kt | 64 +++++++++---------- .../ui/consent/DccReissuanceAdapter.kt | 4 +- .../CertificateReissuanceExtensionTest.kt | 1 - 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt index cffd5fda6ce..d5ebf84e7b9 100644 --- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt +++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/dccreissuance/ui/consent/acccerts/DccReissuanceAccCertsFragmentTest.kt @@ -46,43 +46,43 @@ class DccReissuanceAccCertsFragmentTest : BaseUITest() { private val args = DccReissuanceAccCertsFragmentArgs(personIdentifierCode = "personIdentifierCode").toBundle() private val certificateList = mutableListOf( - DccReissuanceCertificateCard.Item( - mockk { - every { nameData } returns mockk { - every { fullName } returns "Andrea Schneider" - } + DccReissuanceCertificateCard.Item( + mockk { + every { nameData } returns mockk { + every { fullName } returns "Andrea Schneider" + } - every { vaccination } returns mockk { - every { doseNumber } returns 2 - every { totalSeriesOfDoses } returns 2 - every { vaccinatedOn } returns LocalDate.parse("2022-01-15") - every { personIdentifier } returns CertificatePersonIdentifier( - dateOfBirthFormatted = "1980-06-01", - lastNameStandardized = "Schneider", - firstNameStandardized = "Andrea" - ) - } + every { vaccination } returns mockk { + every { doseNumber } returns 2 + every { totalSeriesOfDoses } returns 2 + every { vaccinatedOn } returns LocalDate.parse("2022-01-15") + every { personIdentifier } returns CertificatePersonIdentifier( + dateOfBirthFormatted = "1980-06-01", + lastNameStandardized = "Schneider", + firstNameStandardized = "Andrea" + ) + } + } + ), + DccReissuanceCertificateCard.Item( + mockk { + every { nameData } returns mockk { + every { fullName } returns "Andrea Schneider" } - ), - DccReissuanceCertificateCard.Item( - mockk { - every { nameData } returns mockk { - every { fullName } returns "Andrea Schneider" - } - every { vaccination } returns mockk { - every { doseNumber } returns 1 - every { totalSeriesOfDoses } returns 2 - every { vaccinatedOn } returns LocalDate.parse("2021-10-17") - every { personIdentifier } returns CertificatePersonIdentifier( - dateOfBirthFormatted = "1980-06-01", - lastNameStandardized = "Schneider", - firstNameStandardized = "Andrea" - ) - } + every { vaccination } returns mockk { + every { doseNumber } returns 1 + every { totalSeriesOfDoses } returns 2 + every { vaccinatedOn } returns LocalDate.parse("2021-10-17") + every { personIdentifier } returns CertificatePersonIdentifier( + dateOfBirthFormatted = "1980-06-01", + lastNameStandardized = "Schneider", + firstNameStandardized = "Andrea" + ) } - ) + } ) + ) @Before fun setup() { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt index 57c1d8df05a..42a04c72f72 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/dccreissuance/ui/consent/DccReissuanceAdapter.kt @@ -23,7 +23,9 @@ class DccReissuanceAdapter : listOf( StableIdMod(data), DataBinderMod>(data), - TypedVHCreatorMod({ data[it] is DccReissuanceCertificateCard.Item }) { DccReissuanceCertificateCard(it) } + TypedVHCreatorMod({ data[it] is DccReissuanceCertificateCard.Item }) { + DccReissuanceCertificateCard(it) + } ) ) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt index fec2b25e8dc..aac77a5c628 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/ccl/dccwalletinfo/model/CertificateReissuanceExtensionTest.kt @@ -158,5 +158,4 @@ internal class CertificateReissuanceExtensionTest : BaseTest() { ) set.size shouldBe 1 } - }