Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove work mode #161

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -42,8 +42,8 @@ class RecoveryValidationStrategy : ValidationStrategy {
val startDaysToAdd = if (recoveryBis) ruleSet.getRecoveryCertPVStartDay() else ruleSet.getRecoveryCertStartDayUnified(countryCode)

val endDaysToAdd = when {
scanMode == ScanMode.SCHOOL -> ruleSet.getRecoveryCertEndDaySchool()
recoveryBis -> ruleSet.getRecoveryCertPvEndDay()
scanMode == ScanMode.SCHOOL -> ruleSet.getRecoveryCertEndDaySchool()
else -> ruleSet.getRecoveryCertEndDayUnified(countryCode)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ class TestValidationStrategy : ValidationStrategy {
LocalDateTime.now().isBefore(startDate) -> CertificateStatus.NOT_VALID_YET
LocalDateTime.now().isAfter(endDate) -> CertificateStatus.EXPIRED
isTestNotAllowed -> CertificateStatus.NOT_VALID
else -> {
val birthDate = certificateModel.dateOfBirth?.toValidDateOfBirth()

if (birthDate?.getAge()!! >= Const.VACCINE_MANDATORY_AGE && certificateModel.scanMode == ScanMode.WORK) CertificateStatus.NOT_VALID
else CertificateStatus.VALID
}
else -> CertificateStatus.VALID
}
} catch (e: Exception) {
return CertificateStatus.NOT_EU_DCC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class VaccineValidationStrategy : ValidationStrategy {
ScanMode.STRENGTHENED -> vaccineStrengthenedStrategy(certificateModel, ruleSet)
ScanMode.BOOSTER -> vaccineBoosterStrategy(certificateModel, ruleSet)
ScanMode.SCHOOL -> vaccineSchoolStrategy(certificateModel, ruleSet)
ScanMode.WORK -> vaccineWorkStrategy(certificateModel, ruleSet)
ScanMode.ENTRY_ITALY -> vaccineEntryItalyStrategy(certificateModel, ruleSet)
else -> {
CertificateStatus.NOT_EU_DCC
Expand Down Expand Up @@ -183,7 +182,7 @@ class VaccineValidationStrategy : ValidationStrategy {

private fun vaccineBoosterStrategy(certificateModel: CertificateModel, ruleSet: RuleSet): CertificateStatus {
val vaccination = certificateModel.vaccinations?.last()!!
val country = vaccination.countryOfVaccination
vaccination.countryOfVaccination
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicola-95 could this line be removed?

val dateOfVaccination = vaccination.dateOfVaccination.toLocalDate()

val startDaysToAdd =
Expand Down Expand Up @@ -242,18 +241,6 @@ class VaccineValidationStrategy : ValidationStrategy {
}
}

private fun vaccineWorkStrategy(certificateModel: CertificateModel, ruleSet: RuleSet): CertificateStatus {
val birthDate = certificateModel.dateOfBirth?.toValidDateOfBirth()
return when {
birthDate!!.getAge() >= Const.VACCINE_MANDATORY_AGE -> {
vaccineStrengthenedStrategy(certificateModel, ruleSet)
}
else -> {
vaccineStandardStrategy(certificateModel, ruleSet)
}
}
}

private fun vaccineEntryItalyStrategy(certificateModel: CertificateModel, ruleSet: RuleSet): CertificateStatus {
val vaccination = certificateModel.vaccinations?.last()!!
val dateOfVaccination = vaccination.dateOfVaccination.toLocalDate()
Expand Down