From 648000686de76eebc3c0b1a01224dff3c15ebdc4 Mon Sep 17 00:00:00 2001 From: stylianosgakis Date: Thu, 12 Oct 2023 16:34:25 +0200 Subject: [PATCH 1/2] Fix breaking GQL changes --- .../graphql/insurance/InsuranceContractsQuery.graphql | 5 +---- .../insurance/QueryGetUpcomingRenewalReminder.graphql | 6 +++--- .../graphql/notifications/MemberDeviceRegister.graphql | 2 +- .../insurances/data/GetInsuranceContractsUseCase.kt | 2 +- .../memberreminders/GetUpcomingRenewalRemindersUseCase.kt | 7 ++++--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/InsuranceContractsQuery.graphql b/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/InsuranceContractsQuery.graphql index c62f1e1de8..ec06ebb685 100644 --- a/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/InsuranceContractsQuery.graphql +++ b/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/InsuranceContractsQuery.graphql @@ -15,10 +15,7 @@ fragment ContractFragment on Contract { masterInceptionDate terminationDate exposureDisplayName - supportsAddressChange - upcomingRenewal { - renewalDate - } + supportsMoving currentAgreement { ...AgreementFragment } diff --git a/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/QueryGetUpcomingRenewalReminder.graphql b/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/QueryGetUpcomingRenewalReminder.graphql index 3090bcd3b4..5a554ad64f 100644 --- a/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/QueryGetUpcomingRenewalReminder.graphql +++ b/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/insurance/QueryGetUpcomingRenewalReminder.graphql @@ -6,9 +6,9 @@ query GetUpcomingRenewalReminder { displayName } } - upcomingRenewal { - renewalDate - draftCertificateUrl + upcomingChangedAgreement { + activeFrom + certificateUrl } } } diff --git a/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/notifications/MemberDeviceRegister.graphql b/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/notifications/MemberDeviceRegister.graphql index c111d813ac..8cd72a83ae 100644 --- a/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/notifications/MemberDeviceRegister.graphql +++ b/app/apollo/apollo-octopus-public/src/main/graphql/com/hedvig/android/apollo/octopus/graphql/notifications/MemberDeviceRegister.graphql @@ -1,3 +1,3 @@ mutation MemberDeviceRegister($token: String!) { - memberDeviceRegister(input: {type: "ANDROID", token: $token}) + memberDeviceRegister(input: {platform: ANDROID, token: $token}) } diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt index a5c2d60d79..8e6690e243 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt @@ -43,7 +43,7 @@ private fun ContractFragment.toContract(isTerminated: Boolean = false): Insuranc displayName = currentAgreement.productVariant.displayName, exposureDisplayName = exposureDisplayName, inceptionDate = masterInceptionDate, - renewalDate = upcomingRenewal.renewalDate, + renewalDate = upcomingChangedAgreement?.activeFrom, terminationDate = terminationDate, currentAgreement = Agreement( activeFrom = currentAgreement.activeFrom, diff --git a/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCase.kt b/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCase.kt index 0b6b26845f..221984f468 100644 --- a/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCase.kt +++ b/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCase.kt @@ -35,11 +35,12 @@ internal class GetUpcomingRenewalRemindersUseCaseImpl( .activeContracts val upcomingRenewals: NonEmptyList? = contracts - .map { contract -> + .mapNotNull { contract -> + val upcomingChangedAgreement = contract.upcomingChangedAgreement ?: return@mapNotNull null UpcomingRenewal( contract.currentAgreement.productVariant.displayName, - contract.upcomingRenewal.renewalDate, - contract.upcomingRenewal.draftCertificateUrl, + upcomingChangedAgreement.activeFrom, + upcomingChangedAgreement.certificateUrl, ) } .filter { upcomingRenewal -> From 9354478588a828bc6859aa8615553a3a3efc439d Mon Sep 17 00:00:00 2001 From: stylianosgakis Date: Thu, 12 Oct 2023 17:03:10 +0200 Subject: [PATCH 2/2] Fix tests according to new API --- .../GetUpcomingRenewalRemindersUseCaseTest.kt | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/app/member-reminders/member-reminders-public/src/test/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCaseTest.kt b/app/member-reminders/member-reminders-public/src/test/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCaseTest.kt index 4b9bd1dde3..f7d87c00b2 100644 --- a/app/member-reminders/member-reminders-public/src/test/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCaseTest.kt +++ b/app/member-reminders/member-reminders-public/src/test/kotlin/com/hedvig/android/memberreminders/GetUpcomingRenewalRemindersUseCaseTest.kt @@ -21,7 +21,6 @@ import kotlinx.datetime.toLocalDateTime import octopus.GetUpcomingRenewalReminderQuery import octopus.type.buildAgreement import octopus.type.buildContract -import octopus.type.buildContractRenewal import octopus.type.buildMember import octopus.type.buildProductVariant import org.junit.Rule @@ -56,9 +55,9 @@ class GetUpcomingRenewalRemindersUseCaseTest { displayName = "display name" } } - upcomingRenewal = buildContractRenewal { - renewalDate = upcomingRenewalLocalDate - draftCertificateUrl = "draftUrl" + upcomingChangedAgreement = buildAgreement { + activeFrom = upcomingRenewalLocalDate + certificateUrl = "draftUrl" } }, ) @@ -91,9 +90,9 @@ class GetUpcomingRenewalRemindersUseCaseTest { displayName = "#$index" } } - upcomingRenewal = buildContractRenewal { - renewalDate = clock.now().plus((index + 1).days).toLocalDateTime(TimeZone.UTC).date - draftCertificateUrl = "url#$index" + upcomingChangedAgreement = buildAgreement { + activeFrom = clock.now().plus((index + 1).days).toLocalDateTime(TimeZone.UTC).date + certificateUrl = "url#$index" } } } @@ -133,9 +132,9 @@ class GetUpcomingRenewalRemindersUseCaseTest { displayName = "display name" } } - upcomingRenewal = buildContractRenewal { - renewalDate = upcomingRenewalLocalDate - draftCertificateUrl = "draftUrl" + upcomingChangedAgreement = buildAgreement { + activeFrom = upcomingRenewalLocalDate + certificateUrl = "draftUrl" } } } @@ -166,9 +165,9 @@ class GetUpcomingRenewalRemindersUseCaseTest { displayName = "#$index" } } - upcomingRenewal = buildContractRenewal { - renewalDate = clock.now().minus(index.days).toLocalDateTime(TimeZone.UTC).date - draftCertificateUrl = "url#$index" + upcomingChangedAgreement = buildAgreement { + activeFrom = clock.now().minus(index.days).toLocalDateTime(TimeZone.UTC).date + certificateUrl = "url#$index" } } } @@ -206,9 +205,9 @@ class GetUpcomingRenewalRemindersUseCaseTest { displayName = "#$index" } } - upcomingRenewal = buildContractRenewal { - renewalDate = (clock.now() + renewalOffsets[index]!!).toLocalDateTime(TimeZone.UTC).date - draftCertificateUrl = "url#$index" + upcomingChangedAgreement = buildAgreement { + activeFrom = (clock.now() + renewalOffsets[index]!!).toLocalDateTime(TimeZone.UTC).date + certificateUrl = "url#$index" } } }