From cf13a16d83e2d207ff9cc2bc7f5c59c3541512fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Honor=C3=A9?= Date: Mon, 22 Jan 2024 17:57:35 +0000 Subject: [PATCH] refactoring --- .../handlers/AmendmentHandler.scala | 4 +- .../handlers/EstimationHandler.scala | 9 +- .../handlers/NotificationHandler.scala | 6 +- ...grationAmendment.scala => Amendment.scala} | 33 ++---- ...ationEstimation.scala => Estimation.scala} | 33 ++---- ...nPriceCapping.scala => PriceCapping.scala} | 2 +- ...ationStaticData.scala => StaticData.scala} | 2 +- .../model/AmendmentData.scala | 4 +- .../Newspaper2024MigrationTest.scala | 108 +++++++++--------- 9 files changed, 84 insertions(+), 117 deletions(-) rename lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/{Newspaper2024MigrationAmendment.scala => Amendment.scala} (60%) rename lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/{Newspaper2024MigrationEstimation.scala => Estimation.scala} (88%) rename lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/{Newspaper2024MigrationPriceCapping.scala => PriceCapping.scala} (99%) rename lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/{Newspaper2024MigrationStaticData.scala => StaticData.scala} (99%) diff --git a/lambda/src/main/scala/pricemigrationengine/handlers/AmendmentHandler.scala b/lambda/src/main/scala/pricemigrationengine/handlers/AmendmentHandler.scala index 9a1d9b17a..fa3c731ea 100644 --- a/lambda/src/main/scala/pricemigrationengine/handlers/AmendmentHandler.scala +++ b/lambda/src/main/scala/pricemigrationengine/handlers/AmendmentHandler.scala @@ -7,7 +7,7 @@ import pricemigrationengine.migrations._ import pricemigrationengine.services._ import zio.{Clock, ZIO} import java.time.{LocalDate, LocalDateTime, ZoneOffset} -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationAmendment +import pricemigrationengine.migrations.newspaper2024migration /** Carries out price-rise amendments in Zuora. */ @@ -211,7 +211,7 @@ object AmendmentHandler extends CohortHandler { ) case Newspaper2024 => ZIO.fromEither( - Newspaper2024MigrationAmendment.subscriptionToZuoraSubscriptionUpdate( + newspaper2024migration.Amendment.subscriptionToZuoraSubscriptionUpdate( subscriptionBeforeUpdate, startDate, ) diff --git a/lambda/src/main/scala/pricemigrationengine/handlers/EstimationHandler.scala b/lambda/src/main/scala/pricemigrationengine/handlers/EstimationHandler.scala index e4f827d12..343ae6985 100644 --- a/lambda/src/main/scala/pricemigrationengine/handlers/EstimationHandler.scala +++ b/lambda/src/main/scala/pricemigrationengine/handlers/EstimationHandler.scala @@ -1,6 +1,6 @@ package pricemigrationengine.handlers -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationEstimation +import pricemigrationengine.migrations.newspaper2024migration import pricemigrationengine.model.CohortTableFilter._ import pricemigrationengine.model._ import pricemigrationengine.services._ @@ -147,7 +147,7 @@ object EstimationHandler extends CohortHandler { MigrationType(cohortSpec) match { case Membership2023Monthlies => 1 case Membership2023Annuals => 1 - case Newspaper2024 => Newspaper2024MigrationEstimation.startDateSpreadPeriod(subscription) + case Newspaper2024 => newspaper2024migration.Estimation.startDateSpreadPeriod(subscription) case _ => 3 } } else 1 @@ -168,8 +168,9 @@ object EstimationHandler extends CohortHandler { // nature of that migration), which also takes the subscription. val startDateLowerBound1 = MigrationType(cohortSpec) match { - case Newspaper2024 => Newspaper2024MigrationEstimation.startDateGeneralLowerbound(cohortSpec, today, subscription) - case _ => startDateGeneralLowerbound(cohortSpec, today) + case Newspaper2024 => + newspaper2024migration.Estimation.startDateGeneralLowerbound(cohortSpec, today, subscription) + case _ => startDateGeneralLowerbound(cohortSpec, today) } // We now respect the policy of not increasing members during their first year diff --git a/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala b/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala index b3bc6348f..b6833e8ce 100644 --- a/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala +++ b/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala @@ -6,7 +6,7 @@ import pricemigrationengine.model.membershipworkflow._ import pricemigrationengine.services._ import zio.{Clock, ZIO} import com.gu.i18n -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationStaticData +import pricemigrationengine.migrations.newspaper2024migration import java.time.LocalDate import java.time.format.DateTimeFormatter @@ -34,7 +34,7 @@ object NotificationHandler extends CohortHandler { case Membership2023Annuals => 33 case SupporterPlus2023V1V2MA => 33 case DigiSubs2023 => 33 - case Newspaper2024 => Newspaper2024MigrationStaticData.maxLeadTime + case Newspaper2024 => newspaper2024migration.StaticData.maxLeadTime case Legacy => 49 } } @@ -45,7 +45,7 @@ object NotificationHandler extends CohortHandler { case Membership2023Annuals => 31 case SupporterPlus2023V1V2MA => 31 case DigiSubs2023 => 31 - case Newspaper2024 => Newspaper2024MigrationStaticData.minLeadTime + case Newspaper2024 => newspaper2024migration.StaticData.minLeadTime case Legacy => 35 } } diff --git a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationAmendment.scala b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Amendment.scala similarity index 60% rename from lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationAmendment.scala rename to lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Amendment.scala index 775674ecb..41f4fbc59 100644 --- a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationAmendment.scala +++ b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Amendment.scala @@ -1,19 +1,19 @@ package pricemigrationengine.migrations.newspaper2024migration import pricemigrationengine.model._ -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationStaticData._ -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationEstimation._ +import pricemigrationengine.migrations.newspaper2024migration.StaticData._ +import pricemigrationengine.migrations.newspaper2024migration.Estimation._ import java.time.LocalDate -object Newspaper2024MigrationAmendment { +object Amendment { def subscriptionToNewChargeDistribution2024(subscription: ZuoraSubscription): Option[ChargeDistribution2024] = { - val priceCorrectionFactor = Newspaper2024MigrationPriceCapping.priceCorrectionFactor(subscription) + val priceCorrectionFactor = PriceCapping.priceCorrectionFactor(subscription) for { - data2024 <- Newspaper2024MigrationEstimation + data2024 <- Estimation .subscriptionToSubscriptionData2024(subscription) .toOption - priceDistribution <- Newspaper2024MigrationStaticData.priceDistributionLookup( + priceDistribution <- StaticData.priceDistributionLookup( data2024.productName, data2024.billingPeriod, data2024.ratePlanName @@ -47,26 +47,9 @@ object Newspaper2024MigrationAmendment { subscription: ZuoraSubscription, effectiveDate: LocalDate, ): Either[AmendmentDataFailure, ZuoraSubscriptionUpdate] = { - - def transform1[T](option: Option[T]): Either[AmendmentDataFailure, T] = { - option match { - case None => Left(AmendmentDataFailure("error")) - case Some(ratePlanCharge) => Right(ratePlanCharge) - } - } - - def transform2[T](data: Either[String, T]): Either[AmendmentDataFailure, T] = { - data match { - case Left(string) => Left(AmendmentDataFailure(string)) - case Right(t) => Right(t) - } - } - for { - data2024 <- transform2[SubscriptionData2024]( - Newspaper2024MigrationEstimation.subscriptionToSubscriptionData2024(subscription) - ) - chargeDistribution <- transform1[ChargeDistribution2024](subscriptionToNewChargeDistribution2024(subscription)) + data2024 <- Estimation.subscriptionToSubscriptionData2024(subscription).left.map(AmendmentDataFailure) + chargeDistribution <- subscriptionToNewChargeDistribution2024(subscription).toRight(AmendmentDataFailure("error")) } yield ZuoraSubscriptionUpdate( add = List( AddZuoraRatePlan( diff --git a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationEstimation.scala b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Estimation.scala similarity index 88% rename from lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationEstimation.scala rename to lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Estimation.scala index 4617f226c..07955fcd1 100644 --- a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationEstimation.scala +++ b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Estimation.scala @@ -3,7 +3,7 @@ import pricemigrationengine.model._ import java.time.LocalDate -object Newspaper2024MigrationEstimation { +object Estimation { // -------------------------------------------------------------------------------------------- @@ -83,7 +83,7 @@ object Newspaper2024MigrationEstimation { (price: BigDecimal, ratePlanCharge: ZuoraRatePlanCharge) => price + ratePlanCharge.price.getOrElse(BigDecimal(0)) ) - targetRatePlanId <- Newspaper2024MigrationStaticData.ratePlanIdLookUp(productName, ratePlan.ratePlanName) + targetRatePlanId <- StaticData.ratePlanIdLookUp(productName, ratePlan.ratePlanName) } yield SubscriptionData2024( productName = productName, ratePlan = ratePlan, @@ -92,10 +92,7 @@ object Newspaper2024MigrationEstimation { currency = currency, currentPrice = currentPrice, targetRatePlanId = targetRatePlanId - )) match { - case Some(data) => Right(data) - case _ => Left(s"[error: 0e218c37] Could not determine SubscriptionData2024 for subscription ${subscription}") - } + )).toRight(s"[error: 0e218c37] Could not determine SubscriptionData2024 for subscription ${subscription}") } case _ => Left( @@ -120,10 +117,10 @@ object Newspaper2024MigrationEstimation { // The price correction factor is meant to be 1 except in the case of // subscriptions with capping in which case the correction factor will have been precomputed // from the data generated by Matt - val priceCorrectionFactor = Newspaper2024MigrationPriceCapping.priceCorrectionFactor(subscription) + val priceCorrectionFactor = PriceCapping.priceCorrectionFactor(subscription) for { data2024 <- subscriptionToSubscriptionData2024(subscription).toOption - price <- Newspaper2024MigrationStaticData.priceLookup( + price <- StaticData.priceLookup( data2024.productName, data2024.billingPeriod, data2024.ratePlanName @@ -137,24 +134,10 @@ object Newspaper2024MigrationEstimation { // PriceData(currency: Currency, oldPrice: BigDecimal, newPrice: BigDecimal, billingPeriod: String) - def transform1[T](option: Option[T]): Either[AmendmentDataFailure, T] = { - option match { - case None => Left(AmendmentDataFailure("error")) - case Some(ratePlanCharge) => Right(ratePlanCharge) - } - } - - def transform2[T](data: Either[String, T]): Either[AmendmentDataFailure, T] = { - data match { - case Left(string) => Left(AmendmentDataFailure(string)) - case Right(t) => Right(t) - } - } - for { - data2024 <- transform2[SubscriptionData2024](subscriptionToSubscriptionData2024(subscription)) + data2024 <- subscriptionToSubscriptionData2024(subscription).left.map(AmendmentDataFailure) oldPrice = data2024.currentPrice - newPrice <- transform1[BigDecimal](subscriptionToNewPrice(subscription)) + newPrice <- subscriptionToNewPrice(subscription).toRight(AmendmentDataFailure("error")) } yield PriceData( data2024.currency, oldPrice, @@ -234,7 +217,7 @@ object Newspaper2024MigrationEstimation { datesMax( earliestPriceMigrationStartDate, today.plusDays( - Newspaper2024MigrationStaticData.minLeadTime + 1 + StaticData.minLeadTime + 1 ) // +1 because we need to be strictly over minLeadTime days away. Exactly minLeadTime is not enough. ) } diff --git a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationPriceCapping.scala b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/PriceCapping.scala similarity index 99% rename from lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationPriceCapping.scala rename to lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/PriceCapping.scala index 482f5e135..701d208dc 100644 --- a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationPriceCapping.scala +++ b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/PriceCapping.scala @@ -3,7 +3,7 @@ import pricemigrationengine.model._ import java.time.LocalDate -object Newspaper2024MigrationPriceCapping { +object PriceCapping { // The engine has a notion of capping, but it would not work with this migration // Instead, Matt S. provided us with a list of subscriptions which need to be capped diff --git a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationStaticData.scala b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/StaticData.scala similarity index 99% rename from lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationStaticData.scala rename to lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/StaticData.scala index 5f110f854..2ea6ddc55 100644 --- a/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Newspaper2024MigrationStaticData.scala +++ b/lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/StaticData.scala @@ -3,7 +3,7 @@ import pricemigrationengine.model._ import java.time.LocalDate -object Newspaper2024MigrationStaticData { +object StaticData { val maxLeadTime = 40 val minLeadTime = 35 diff --git a/lambda/src/main/scala/pricemigrationengine/model/AmendmentData.scala b/lambda/src/main/scala/pricemigrationengine/model/AmendmentData.scala index a0af467b0..8d6979867 100644 --- a/lambda/src/main/scala/pricemigrationengine/model/AmendmentData.scala +++ b/lambda/src/main/scala/pricemigrationengine/model/AmendmentData.scala @@ -1,6 +1,6 @@ package pricemigrationengine.model -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationEstimation +import pricemigrationengine.migrations.newspaper2024migration import pricemigrationengine.migrations.{DigiSubs2023Migration, GuardianWeeklyMigration, Membership2023Migration} import pricemigrationengine.model.ZuoraProductCatalogue.{homeDeliveryRatePlans, productPricingMap} @@ -339,7 +339,7 @@ object AmendmentData { subscription ) case Newspaper2024 => - Newspaper2024MigrationEstimation.priceData( + newspaper2024migration.Estimation.priceData( subscription ) case Legacy => priceDataWithRatePlanMatching(account, catalogue, subscription, invoiceList, nextServiceStartDate) diff --git a/lambda/src/test/scala/pricemigrationengine/migrations/Newspaper2024MigrationTest.scala b/lambda/src/test/scala/pricemigrationengine/migrations/Newspaper2024MigrationTest.scala index 8635f4d63..0cd3ddb8a 100644 --- a/lambda/src/test/scala/pricemigrationengine/migrations/Newspaper2024MigrationTest.scala +++ b/lambda/src/test/scala/pricemigrationengine/migrations/Newspaper2024MigrationTest.scala @@ -4,13 +4,13 @@ import pricemigrationengine.model._ import java.time.LocalDate import pricemigrationengine.Fixtures -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationEstimation._ -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationAmendment._ +import pricemigrationengine.migrations.newspaper2024migration.Estimation._ +import pricemigrationengine.migrations.newspaper2024migration.Amendment._ import pricemigrationengine.migrations.newspaper2024migration.{ - Newspaper2024MigrationEstimation, - Newspaper2024MigrationStaticData + Estimation, + StaticData } -import pricemigrationengine.migrations.newspaper2024migration.Newspaper2024MigrationStaticData.{ +import pricemigrationengine.migrations.newspaper2024migration.StaticData.{ ChargeDistribution2024, IndividualCharge2024 } @@ -31,15 +31,15 @@ class Newspaper2024MigrationTest extends munit.FunSuite { test("Newspaper2024Migration: Price lookup is correct") { assertEquals( - Newspaper2024MigrationStaticData.priceLookup("Newspaper Delivery", Monthly, "Weekend"), + StaticData.priceLookup("Newspaper Delivery", Monthly, "Weekend"), Some(BigDecimal(31.99)) ) assertEquals( - Newspaper2024MigrationStaticData.priceLookup("Newspaper Digital Voucher", Annual, "Sixday"), + StaticData.priceLookup("Newspaper Digital Voucher", Annual, "Sixday"), Some(BigDecimal(683.88)) ) - assertEquals(Newspaper2024MigrationStaticData.priceLookup("Newspaper Digital Voucher", Annual, "Sixday+"), None) - assertEquals(Newspaper2024MigrationStaticData.priceLookup("Non existent product", Annual, "Weekend"), None) + assertEquals(StaticData.priceLookup("Newspaper Digital Voucher", Annual, "Sixday+"), None) + assertEquals(StaticData.priceLookup("Non existent product", Annual, "Weekend"), None) } // -- product name ------------------------------------------------------- @@ -1071,60 +1071,60 @@ class Newspaper2024MigrationTest extends munit.FunSuite { test("Newspaper2024Migration | price data is correct | NewspaperHomeDelivery-Monthly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperHomeDelivery-Monthly/subscription.json") val priceData = PriceData("GBP", BigDecimal(33.76), BigDecimal(40.99), "Month") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperHomeDelivery-Quarterly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperHomeDelivery-Quarterly/subscription.json") val priceData = PriceData("GBP", BigDecimal(83.97), BigDecimal(95.97), "Quarter") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperSubscriptionCard-Monthly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-Monthly/subscription.json") val priceData = PriceData("GBP", BigDecimal(31.99), BigDecimal(34.99), "Month") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperSubscriptionCard-Quarterly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-Quarterly/subscription.json") val priceData = PriceData("GBP", BigDecimal(68.97), BigDecimal(77.97), "Quarter") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperSubscriptionCard-SemiAnnual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-SemiAnnual/subscription.json") val priceData = PriceData("GBP", BigDecimal(287.94), BigDecimal(341.94), "Semi_Annual") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperSubscriptionCard-Annual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-Annual/subscription.json") val priceData = PriceData("GBP", BigDecimal(731.88), BigDecimal(779.88), "Annual") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperVoucherBook-Monthly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-Monthly/subscription.json") val priceData = PriceData("GBP", BigDecimal(31.99), BigDecimal(34.99), "Month") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperVoucherBook-Quarterly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-Quarterly/subscription.json") val priceData = PriceData("GBP", BigDecimal(95.97), BigDecimal(104.97), "Quarter") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperVoucherBook-SemiAnnual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-SemiAnnual/subscription.json") val priceData = PriceData("GBP", BigDecimal(191.94), BigDecimal(209.94), "Semi_Annual") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } test("Newspaper2024Migration | price data is correct | NewspaperVoucherBook-Annual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-Annual/subscription.json") val priceData = PriceData("GBP", BigDecimal(383.88), BigDecimal(419.88), "Annual") - assertEquals(Newspaper2024MigrationEstimation.priceData(subscription), Right(priceData)) + assertEquals(Estimation.priceData(subscription), Right(priceData)) } // -- subscription to batch Id ------------------------------------------------------- @@ -1138,51 +1138,51 @@ class Newspaper2024MigrationTest extends munit.FunSuite { test("Newspaper2024Migration | batchId is correct | NewspaperHomeDelivery-Monthly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperHomeDelivery-Monthly/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MonthliesPart1)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MonthliesPart1)) } test("Newspaper2024Migration | batchId is correct | NewspaperHomeDelivery-Quarterly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperHomeDelivery-Quarterly/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } test("Newspaper2024Migration | batchId is correct | NewspaperSubscriptionCard-Monthly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-Monthly/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MonthliesPart1)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MonthliesPart1)) } test("Newspaper2024Migration | batchId is correct | NewspaperSubscriptionCard-Quarterly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-Quarterly/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } test("Newspaper2024Migration | batchId is correct | NewspaperSubscriptionCard-SemiAnnual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-SemiAnnual/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } test("Newspaper2024Migration | batchId is correct | NewspaperSubscriptionCard-Annual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperSubscriptionCard-Annual/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } test("Newspaper2024Migration | batchId is correct | NewspaperVoucherBook-Monthly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-Monthly/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MonthliesPart2)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MonthliesPart2)) } test("Newspaper2024Migration | batchId is correct | NewspaperVoucherBook-Quarterly") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-Quarterly/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } test("Newspaper2024Migration | batchId is correct | NewspaperVoucherBook-SemiAnnual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-SemiAnnual/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } test("Newspaper2024Migration | batchId is correct | NewspaperVoucherBook-Annual") { val subscription = Fixtures.subscriptionFromJson("Newspaper2024/NewspaperVoucherBook-Annual/subscription.json") - assertEquals(Newspaper2024MigrationEstimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) + assertEquals(Estimation.subscriptionToBatchId(subscription), Right(MoreThanMonthlies)) } // -- spread period ------------------------------------------------------- @@ -1248,9 +1248,9 @@ class Newspaper2024MigrationTest extends munit.FunSuite { // This section perform a check of the form assertEquals( - Newspaper2024MigrationStaticData.newspaperHomeDeliveryMonthlyPrices.get("Everyday").get, - Newspaper2024MigrationStaticData.chargeDistributionToPrice( - Newspaper2024MigrationStaticData.newspaperHomeDeliveryMonthlyChargeDistributionsMap.get("Everyday").get + StaticData.newspaperHomeDeliveryMonthlyPrices.get("Everyday").get, + StaticData.chargeDistributionToPrice( + StaticData.newspaperHomeDeliveryMonthlyChargeDistributionsMap.get("Everyday").get ) ) @@ -1260,8 +1260,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { List( ( - Newspaper2024MigrationStaticData.newspaperHomeDeliveryMonthlyPrices, - Newspaper2024MigrationStaticData.newspaperHomeDeliveryMonthlyChargeDistributionsMap, + StaticData.newspaperHomeDeliveryMonthlyPrices, + StaticData.newspaperHomeDeliveryMonthlyChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1276,8 +1276,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperHomeDeliveryQuarterlyPrices, - Newspaper2024MigrationStaticData.newspaperHomeDeliveryQuarterlyChargeDistributionsMap, + StaticData.newspaperHomeDeliveryQuarterlyPrices, + StaticData.newspaperHomeDeliveryQuarterlyChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1287,8 +1287,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperSubscriptionCardMonthlyPrices, - Newspaper2024MigrationStaticData.newspaperSubscriptionCardMonthlyChargeDistributionsMap, + StaticData.newspaperSubscriptionCardMonthlyPrices, + StaticData.newspaperSubscriptionCardMonthlyChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1303,8 +1303,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperSubscriptionCardQuarterlyPrices, - Newspaper2024MigrationStaticData.newspaperSubscriptionCardQuarterlyChargeDistributionsMap, + StaticData.newspaperSubscriptionCardQuarterlyPrices, + StaticData.newspaperSubscriptionCardQuarterlyChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1314,8 +1314,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperSubscriptionCardSemiAnnualPrices, - Newspaper2024MigrationStaticData.newspaperSubscriptionCardSemiAnnualChargeDistributionsMap, + StaticData.newspaperSubscriptionCardSemiAnnualPrices, + StaticData.newspaperSubscriptionCardSemiAnnualChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1323,8 +1323,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperSubscriptionCardAnnualPrices, - Newspaper2024MigrationStaticData.newspaperSubscriptionCardAnnualChargeDistributionsMap, + StaticData.newspaperSubscriptionCardAnnualPrices, + StaticData.newspaperSubscriptionCardAnnualChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1332,8 +1332,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperVoucherBookMonthlyPrices, - Newspaper2024MigrationStaticData.newspaperVoucherBookMonthlChargeDistibutionsMap, + StaticData.newspaperVoucherBookMonthlyPrices, + StaticData.newspaperVoucherBookMonthlChargeDistibutionsMap, List( "Everyday", "Sixday", @@ -1348,8 +1348,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperVoucherBookQuarterlyPrices, - Newspaper2024MigrationStaticData.newspaperVoucherBookQuarterlyChargeDistibutionsMap, + StaticData.newspaperVoucherBookQuarterlyPrices, + StaticData.newspaperVoucherBookQuarterlyChargeDistibutionsMap, List( "Everyday", "Sixday", @@ -1361,8 +1361,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperVoucherBookSemiAnnualPrices, - Newspaper2024MigrationStaticData.newspaperVoucherBookSemiAnnualChargeDistributionsMap, + StaticData.newspaperVoucherBookSemiAnnualPrices, + StaticData.newspaperVoucherBookSemiAnnualChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1374,8 +1374,8 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ) ), ( - Newspaper2024MigrationStaticData.newspaperVoucherBookAnnualPrices, - Newspaper2024MigrationStaticData.newspaperVoucherBookAnnualChargeDistributionsMap, + StaticData.newspaperVoucherBookAnnualPrices, + StaticData.newspaperVoucherBookAnnualChargeDistributionsMap, List( "Everyday", "Sixday", @@ -1388,13 +1388,13 @@ class Newspaper2024MigrationTest extends munit.FunSuite { ).foreach { case ( mapper1: Map[String, BigDecimal], - mapper2: Map[String, Newspaper2024MigrationStaticData.ChargeDistribution2024], + mapper2: Map[String, StaticData.ChargeDistribution2024], ratePlanNames: List[String] ) => ratePlanNames.foreach { ratePlanName => assertEquals( mapper1(ratePlanName), - Newspaper2024MigrationStaticData.chargeDistributionToPrice(mapper2(ratePlanName)) + StaticData.chargeDistributionToPrice(mapper2(ratePlanName)) ) } }