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

Screenshot (EXPOSUREAPP-12864) #5188

Merged
merged 27 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
960eae9
add accompanying certificates button
chiljamgossow May 11, 2022
890605f
accompanying certs screen
chiljamgossow May 11, 2022
d0d1a75
klint
chiljamgossow May 11, 2022
674a10e
Merge branch 'release/2.23.x' into feature/13068-accomp-certs-screen
chiljamgossow May 11, 2022
fec0a1f
strings
chiljamgossow May 12, 2022
bf56419
fix test
chiljamgossow May 12, 2022
ec46fbb
fix test
chiljamgossow May 12, 2022
5994ef3
fix test
chiljamgossow May 12, 2022
767d88f
rename
chiljamgossow May 12, 2022
48ea41c
view model test
chiljamgossow May 12, 2022
9657f2b
Merge branch 'release/2.23.x' into feature/13068-accomp-certs-screen
chiljamgossow May 12, 2022
a2dea66
fix merge
chiljamgossow May 12, 2022
772fb8a
sort test
chiljamgossow May 12, 2022
f37005c
Merge branch 'release/2.23.x' into feature/13068-accomp-certs-screen
chiljamgossow May 13, 2022
12f3d8f
ui test
chiljamgossow May 16, 2022
7552747
move adapter declaration
chiljamgossow May 16, 2022
52e1043
Merge branch 'release/2.23.x' into feature/13068-accomp-certs-screen
chiljamgossow May 16, 2022
6b0abdc
Update Corona-Warn-App/src/main/res/values-de/dcc_reissuance_strings.xml
mtwalli May 16, 2022
746f288
Merge branch 'feature/13068-accomp-certs-screen' into feature/12864-s…
chiljamgossow May 16, 2022
a3db9a2
unit test
chiljamgossow May 16, 2022
c012d01
Merge branch 'release/2.23.x' into feature/12864-screenshots
chiljamgossow May 16, 2022
c90b96e
klint
chiljamgossow May 16, 2022
f123858
Merge branch 'release/2.23.x' into feature/12864-screenshots
SamuraiKek May 17, 2022
527a5f2
Merge branch 'release/2.23.x' into feature/12864-screenshots
SamuraiKek May 17, 2022
21e4025
Merge branch 'release/2.23.x' into feature/12864-screenshots
chiljamgossow May 17, 2022
1c550f6
Merge branch 'release/2.23.x' into feature/12864-screenshots
SamuraiKek May 17, 2022
6e743ec
Merge branch 'release/2.23.x' into feature/12864-screenshots
SamuraiKek May 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DccReissuanceConsentFragmentTest : BaseUITest() {

private val state = DccReissuanceConsentViewModel.State(
certificateList = mutableListOf<DccReissuanceItem>(
DccReissuanceConsentCard.Item(
DccReissuanceCertificateCard.Item(
mockk<VaccinationDccV1> {
every { nameData } returns mockk {
every { fullName } returns "Andrea Schneider"
Expand All @@ -66,7 +66,7 @@ class DccReissuanceConsentFragmentTest : BaseUITest() {
}
}
),
DccReissuanceConsentCard.Item(
DccReissuanceCertificateCard.Item(
mockk<VaccinationDccV1> {
every { nameData } returns mockk {
every { fullName } returns "Andrea Schneider"
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DccReissuanceItem>(
DccReissuanceCertificateCard.Item(
mockk<VaccinationDccV1> {
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<VaccinationDccV1> {
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<DccReissuanceAccCertsFragment>(fragmentArgs = args)
}

@Test
@Screenshot
fun capture_fragment() {
launchFragmentInContainer2<DccReissuanceAccCertsFragment>(
testNavHostController = navController,
fragmentArgs = args
)
takeScreenshot<DccReissuanceAccCertsFragment>("1")
}
}

@Module
abstract class DccReissuanceAccCertsFragmentTestModule {
@ContributesAndroidInjector
abstract fun dccReissuanceAccCertsFragment(): DccReissuanceAccCertsFragment
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,6 +134,7 @@ import kotlinx.coroutines.test.TestScope
PersonDetailsFragmentTestModule::class,
BoosterInfoDetailsFragmentTestModule::class,
DccReissuanceConsentFragmentTestModule::class,
DccReissuanceAccCertsFragmentTestModule::class,

// -------- Profile ------------
ProfileCreateFragmentTestModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class DccReissuanceAdapter :
listOf(
StableIdMod(data),
DataBinderMod<DccReissuanceItem, ItemVH<DccReissuanceItem, ViewBinding>>(data),
TypedVHCreatorMod({ data[it] is DccReissuanceConsentCard.Item }) { DccReissuanceConsentCard(it) }
TypedVHCreatorMod({ data[it] is DccReissuanceCertificateCard.Item }) {
DccReissuanceCertificateCard(it)
}
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DccReissuanceConsentCard.Item, DccReissuanceCertificateCardBinding>(
class DccReissuanceCertificateCard(parent: ViewGroup) :
DccReissuanceAdapter.ItemVH<DccReissuanceCertificateCard.Item, DccReissuanceCertificateCardBinding>(
layoutRes = R.layout.dcc_reissuance_certificate_card,
parent = parent
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,7 +47,7 @@ class DccReissuanceAccCertsViewModel @AssistedInject constructor(
null
}
}.sort().map {
DccReissuanceConsentCard.Item(it.data.certificate)
DccReissuanceCertificateCard.Item(it.data.certificate)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +71,7 @@ internal class DccReissuanceAccCertsViewModelTest : BaseTest() {
@Test
fun `getState works`() {
viewModel().certificatesLiveData.getOrAwaitValue() shouldBe listOf(
DccReissuanceConsentCard.Item(metadata)
DccReissuanceCertificateCard.Item(metadata)
)
}

Expand Down