diff --git a/build.sbt b/build.sbt index 4e85d54..13f823d 100644 --- a/build.sbt +++ b/build.sbt @@ -31,7 +31,7 @@ ThisBuild / organization := "app.softnetwork" name := "payment" -ThisBuild / version := "0.2.6.1" +ThisBuild / version := "0.2.7" ThisBuild / scalaVersion := "2.12.15" diff --git a/common/build.sbt b/common/build.sbt index 89a3328..a6f3953 100644 --- a/common/build.sbt +++ b/common/build.sbt @@ -9,7 +9,7 @@ libraryDependencies ++= Seq( "app.softnetwork.scheduler" %% "scheduler-common" % Versions.scheduler, "app.softnetwork.scheduler" %% "scheduler-common" % Versions.scheduler % "protobuf", "app.softnetwork.api" %% "generic-server-api" % Versions.server, - "app.softnetwork.protobuf" %% "scalapb-extensions" % "0.1.5", + "app.softnetwork.protobuf" %% "scalapb-extensions" % "0.1.6", "commons-validator" % "commons-validator" % "1.6" ) diff --git a/common/src/main/scala/app/softnetwork/payment/model/RecurringPaymentDecorator.scala b/common/src/main/scala/app/softnetwork/payment/model/RecurringPaymentDecorator.scala index 026b7c5..a184911 100644 --- a/common/src/main/scala/app/softnetwork/payment/model/RecurringPaymentDecorator.scala +++ b/common/src/main/scala/app/softnetwork/payment/model/RecurringPaymentDecorator.scala @@ -1,17 +1,20 @@ package app.softnetwork.payment.model -import app.softnetwork.time.{now => _, _} - +import app.softnetwork.time._ import app.softnetwork.persistence.now import java.time.LocalDate +import java.util.Date + +import scala.language.implicitConversions trait RecurringPaymentDecorator { _: RecurringPayment => lazy val nextPaymentDate: Option[LocalDate] = { if (`type`.isCard && getCardStatus.isEnded) { None } else { - val today: LocalDate = startDate.getOrElse(now()).toLocalDate + val d: Date = startDate.getOrElse(now()) + val today: LocalDate = d val maybePreviousPayment: Option[LocalDate] = lastRecurringPaymentDate match { case Some(value) => Some(value) case _ => None diff --git a/core/src/main/scala/app/softnetwork/payment/persistence/typed/GenericPaymentBehavior.scala b/core/src/main/scala/app/softnetwork/payment/persistence/typed/GenericPaymentBehavior.scala index ffeeaf5..bde7f4a 100644 --- a/core/src/main/scala/app/softnetwork/payment/persistence/typed/GenericPaymentBehavior.scala +++ b/core/src/main/scala/app/softnetwork/payment/persistence/typed/GenericPaymentBehavior.scala @@ -19,7 +19,7 @@ import app.softnetwork.persistence.message.{BroadcastEvent, CrudEvent} import app.softnetwork.persistence.typed._ import app.softnetwork.scheduler.config.SchedulerSettings import app.softnetwork.serialization.asJson -import app.softnetwork.time.{now => _, _} +import app.softnetwork.time._ import org.slf4j.Logger import app.softnetwork.scheduler.message.SchedulerEvents.{ ExternalEntityToSchedulerEvent, @@ -29,6 +29,7 @@ import app.softnetwork.scheduler.message.SchedulerEvents.{ import app.softnetwork.scheduler.message.{AddSchedule, RemoveSchedule} import app.softnetwork.scheduler.model.Schedule +import java.time.LocalDate import scala.reflect.ClassTag import scala.util.{Failure, Success} @@ -1283,10 +1284,11 @@ trait GenericPaymentBehavior case Some(transaction) => paymentAccount.walletId match { case Some(creditedWalletId) => + val transactionDate: LocalDate = transaction.createdDate directDebitTransaction( transaction.creditedWalletId.getOrElse(creditedWalletId), transaction.id, - transaction.createdDate.minusDays(1) + transactionDate.minusDays(1) ) match { case Some(t) => val lastUpdated = now() @@ -2525,7 +2527,8 @@ trait GenericPaymentBehavior case cmd: DeleteBankAccount => state match { - case Some(_) if PaymentSettings.DisableBankAccountDeletion && !cmd.force.getOrElse(false) => + case Some(_) + if PaymentSettings.DisableBankAccountDeletion && !cmd.force.getOrElse(false) => Effect.none.thenRun(_ => BankAccountDeletionDisabled ~> replyTo) case Some(paymentAccount) => diff --git a/core/src/test/scala/app/softnetwork/payment/model/RecurringPaymentSpec.scala b/core/src/test/scala/app/softnetwork/payment/model/RecurringPaymentSpec.scala index 8258ad6..09e483f 100644 --- a/core/src/test/scala/app/softnetwork/payment/model/RecurringPaymentSpec.scala +++ b/core/src/test/scala/app/softnetwork/payment/model/RecurringPaymentSpec.scala @@ -45,11 +45,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.DAILY) - .withStartDate(now().minusDays(1)) + .withStartDate(LocalDate.now().minusDays(1)) .withEndDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1))) case _ => fail() } } @@ -57,7 +57,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.DAILY) - .withEndDate(now().plusDays(1)) + .withEndDate(LocalDate.now().plusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -68,11 +68,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.DAILY) - .withStartDate(now().plusDays(1)) - .withEndDate(now().plusDays(1)) + .withStartDate(LocalDate.now().plusDays(1)) + .withEndDate(LocalDate.now().plusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusDays(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusDays(1))) case _ => fail() } } @@ -80,11 +80,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.DAILY) - .withEndDate(now().plusDays(1)) + .withEndDate(LocalDate.now().plusDays(1)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusDays(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusDays(1))) case _ => fail() } } @@ -93,7 +93,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.DAILY) .withEndDate(now()) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -115,7 +115,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.DAILY) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => @@ -147,7 +147,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.WEEKLY) - .withEndDate(now().plusWeeks(1)) + .withEndDate(LocalDate.now().plusWeeks(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -158,11 +158,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.WEEKLY) - .withEndDate(now().plusWeeks(1)) + .withEndDate(LocalDate.now().plusWeeks(1)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusWeeks(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusWeeks(1))) case _ => fail() } } @@ -170,11 +170,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.WEEKLY) - .withEndDate(now().plusWeeks(1)) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withEndDate(LocalDate.now().plusWeeks(1)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1).plusWeeks(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1).plusWeeks(1))) case _ => fail() } } @@ -203,7 +203,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.WEEKLY) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => @@ -235,7 +235,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.MONTHLY) - .withEndDate(now().plusMonths(1)) + .withEndDate(LocalDate.now().plusMonths(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -246,11 +246,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.MONTHLY) - .withEndDate(now().plusMonths(1)) + .withEndDate(LocalDate.now().plusMonths(1)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusMonths(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusMonths(1))) case _ => fail() } } @@ -258,11 +258,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.MONTHLY) - .withEndDate(now().plusMonths(1)) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withEndDate(LocalDate.now().plusMonths(1)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1).plusMonths(1))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1).plusMonths(1))) case _ => fail() } } @@ -293,7 +293,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.MONTHLY) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => @@ -325,7 +325,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.QUARTERLY) - .withEndDate(now().plusMonths(3)) + .withEndDate(LocalDate.now().plusMonths(3)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -336,11 +336,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.QUARTERLY) - .withEndDate(now().plusMonths(3)) + .withEndDate(LocalDate.now().plusMonths(3)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusMonths(3))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusMonths(3))) case _ => fail() } } @@ -348,11 +348,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.QUARTERLY) - .withEndDate(now().plusMonths(3)) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withEndDate(LocalDate.now().plusMonths(3)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1).plusMonths(3))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1).plusMonths(3))) case _ => fail() } } @@ -383,7 +383,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.QUARTERLY) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => @@ -415,7 +415,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIANNUAL) - .withEndDate(now().plusMonths(6)) + .withEndDate(LocalDate.now().plusMonths(6)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -426,11 +426,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIANNUAL) - .withEndDate(now().plusMonths(6)) + .withEndDate(LocalDate.now().plusMonths(6)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusMonths(6))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusMonths(6))) case _ => fail() } } @@ -438,11 +438,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIANNUAL) - .withEndDate(now().plusMonths(6)) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withEndDate(LocalDate.now().plusMonths(6)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1).plusMonths(6))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1).plusMonths(6))) case _ => fail() } } @@ -473,7 +473,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIANNUAL) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => @@ -505,7 +505,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.ANNUAL) - .withEndDate(now().plusMonths(12)) + .withEndDate(LocalDate.now().plusMonths(12)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -516,11 +516,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.ANNUAL) - .withEndDate(now().plusMonths(12)) + .withEndDate(LocalDate.now().plusMonths(12)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusMonths(12))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusMonths(12))) case _ => fail() } } @@ -528,11 +528,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.ANNUAL) - .withEndDate(now().plusMonths(12)) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withEndDate(LocalDate.now().plusMonths(12)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1).plusMonths(12))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1).plusMonths(12))) case _ => fail() } } @@ -565,7 +565,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.ANNUAL) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => @@ -597,7 +597,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIMONTHLY) - .withEndDate(now().plusMonths(2)) + .withEndDate(LocalDate.now().plusMonths(2)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => assert(nextPaymentDate.isEqual(now())) @@ -608,11 +608,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIMONTHLY) - .withEndDate(now().plusMonths(2)) + .withEndDate(LocalDate.now().plusMonths(2)) .withLastRecurringPaymentDate(now()) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().plusMonths(2))) + assert(nextPaymentDate.isEqual(LocalDate.now().plusMonths(2))) case _ => fail() } } @@ -620,11 +620,11 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIMONTHLY) - .withEndDate(now().plusMonths(2)) - .withLastRecurringPaymentDate(now().minusDays(1)) + .withEndDate(LocalDate.now().plusMonths(2)) + .withLastRecurringPaymentDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(nextPaymentDate) => - assert(nextPaymentDate.isEqual(now().minusDays(1).plusMonths(2))) + assert(nextPaymentDate.isEqual(LocalDate.now().minusDays(1).plusMonths(2))) case _ => fail() } } @@ -655,7 +655,7 @@ class RecurringPaymentSpec extends AnyWordSpec with Matchers { val recurringPayment = RecurringPayment.defaultInstance .withFrequency(RecurringPayment.RecurringPaymentFrequency.BIMONTHLY) - .withEndDate(now().minusDays(1)) + .withEndDate(LocalDate.now().minusDays(1)) recurringPayment.nextPaymentDate match { case Some(_) => fail() case _ => diff --git a/project/src/main/scala/app/softnetwork/sbt/build/Versions.scala b/project/src/main/scala/app/softnetwork/sbt/build/Versions.scala index 1447802..40ce217 100644 --- a/project/src/main/scala/app/softnetwork/sbt/build/Versions.scala +++ b/project/src/main/scala/app/softnetwork/sbt/build/Versions.scala @@ -2,13 +2,13 @@ package app.softnetwork.sbt.build object Versions { - val genericPersistence = "0.2.6.1" + val genericPersistence = "0.2.6.2" - val scheduler = "0.2.5.3" + val scheduler = "0.2.6" - val server = "0.2.8" + val server = "0.2.9" - val session = "0.1.2" + val session = "0.1.4" val scalatest = "3.1.1" } diff --git a/testkit/src/test/scala/app/softnetwork/payment/handlers/PaymentHandlerSpec.scala b/testkit/src/test/scala/app/softnetwork/payment/handlers/PaymentHandlerSpec.scala index 5ba3a49..094d5bf 100644 --- a/testkit/src/test/scala/app/softnetwork/payment/handlers/PaymentHandlerSpec.scala +++ b/testkit/src/test/scala/app/softnetwork/payment/handlers/PaymentHandlerSpec.scala @@ -7,10 +7,12 @@ import app.softnetwork.payment.message.PaymentMessages._ import app.softnetwork.payment.model.PaymentAccount.User import app.softnetwork.payment.model._ import app.softnetwork.payment.scalatest.PaymentTestKit -import app.softnetwork.time.{now => _, _} +import app.softnetwork.time._ import app.softnetwork.persistence.now import org.scalatest.wordspec.AnyWordSpecLike +import java.time.LocalDate +import scala.language.implicitConversions import scala.util.{Failure, Success} class PaymentHandlerSpec @@ -1040,7 +1042,7 @@ class PaymentHandlerSpec assert(recurringPayment.getNextDebitedAmount == 1000) assert(recurringPayment.getNextFeesAmount == 100) assert(recurringPayment.getNumberOfRecurringPayments == 0) - assert(recurringPayment.getNextRecurringPaymentDate.isEqual(now())) + assert(LocalDate.now().isEqual(recurringPayment.getNextRecurringPaymentDate)) case other => fail(other.toString) } case other => fail(other.toString) @@ -1063,7 +1065,7 @@ class PaymentHandlerSpec val recurringPayment = result.recurringPayment assert(recurringPayment.getCumulatedDebitedAmount == 1000) assert(recurringPayment.getCumulatedFeesAmount == 100) - assert(recurringPayment.getLastRecurringPaymentDate.isEqual(now())) + assert(LocalDate.now().isEqual(recurringPayment.getLastRecurringPaymentDate)) assert(recurringPayment.lastRecurringPaymentTransactionId.isDefined) assert(recurringPayment.getNumberOfRecurringPayments == 1) assert(recurringPayment.nextRecurringPaymentDate.isEmpty) @@ -1077,7 +1079,7 @@ class PaymentHandlerSpec computeExternalUuidWithProfile(customerUuid, Some("customer")), `type` = RecurringPayment.RecurringPaymentType.CARD, frequency = Some(RecurringPayment.RecurringPaymentFrequency.DAILY), - endDate = Some(now().plusDays(1)), + endDate = Some(LocalDate.now().plusDays(1)), fixedNextAmount = Some(true), nextDebitedAmount = Some(1000), nextFeesAmount = Some(100) @@ -1102,7 +1104,7 @@ class PaymentHandlerSpec assert(recurringPayment.getNextFeesAmount == 100) assert(recurringPayment.getNumberOfRecurringPayments == 0) assert(recurringPayment.getCardStatus.isCreated) - assert(recurringPayment.getNextRecurringPaymentDate.isEqual(now())) + assert(LocalDate.now().isEqual(recurringPayment.getNextRecurringPaymentDate)) case other => fail(other.toString) } case other => fail(other.toString) @@ -1134,7 +1136,9 @@ class PaymentHandlerSpec assert(recurringPayment.getNextFeesAmount == 100) assert(recurringPayment.getNumberOfRecurringPayments == 1) assert(recurringPayment.getCardStatus.isInProgress) - assert(recurringPayment.getNextRecurringPaymentDate.isEqual(now().plusDays(1))) + assert( + LocalDate.now().plusDays(1).isEqual(recurringPayment.getNextRecurringPaymentDate) + ) case other => fail(other.toString) } case other => fail(other.toString) diff --git a/testkit/src/test/scala/app/softnetwork/payment/service/PaymentServiceSpec.scala b/testkit/src/test/scala/app/softnetwork/payment/service/PaymentServiceSpec.scala index e19ef91..831d75d 100644 --- a/testkit/src/test/scala/app/softnetwork/payment/service/PaymentServiceSpec.scala +++ b/testkit/src/test/scala/app/softnetwork/payment/service/PaymentServiceSpec.scala @@ -8,11 +8,13 @@ import app.softnetwork.payment.config.PaymentSettings._ import app.softnetwork.payment.message.PaymentMessages._ import app.softnetwork.payment.model._ import app.softnetwork.payment.scalatest.PaymentRouteTestKit -import app.softnetwork.time.{now => _, _} +import app.softnetwork.time._ import app.softnetwork.persistence.now import org.scalatest.wordspec.AnyWordSpecLike import java.net.URLEncoder +import java.time.LocalDate +import scala.language.implicitConversions import scala.util.{Failure, Success} class PaymentServiceSpec extends AnyWordSpecLike with PaymentRouteTestKit { @@ -445,7 +447,11 @@ class PaymentServiceSpec extends AnyWordSpecLike with PaymentRouteTestKit { assert(recurringPayment.nextDebitedAmount.contains(1000)) assert(recurringPayment.nextFeesAmount.contains(100)) assert(recurringPayment.numberOfRecurringPayments.getOrElse(0) == 0) - assert(recurringPayment.nextRecurringPaymentDate.exists(_.isEqual(now()))) + assert( + recurringPayment.nextRecurringPaymentDate.exists( + LocalDate.now().isEqual(_) + ) + ) } } } @@ -464,7 +470,11 @@ class PaymentServiceSpec extends AnyWordSpecLike with PaymentRouteTestKit { val recurringPayment = responseAs[RecurringPaymentView] assert(recurringPayment.cumulatedDebitedAmount.contains(1000)) assert(recurringPayment.cumulatedFeesAmount.contains(100)) - assert(recurringPayment.lastRecurringPaymentDate.exists(_.isEqual(now()))) + assert( + recurringPayment.lastRecurringPaymentDate.exists( + LocalDate.now().isEqual(_) + ) + ) assert(recurringPayment.lastRecurringPaymentTransactionId.isDefined) assert(recurringPayment.numberOfRecurringPayments.contains(1)) assert(recurringPayment.nextRecurringPaymentDate.isEmpty) @@ -480,7 +490,7 @@ class PaymentServiceSpec extends AnyWordSpecLike with PaymentRouteTestKit { "", `type` = RecurringPayment.RecurringPaymentType.CARD, frequency = Some(RecurringPayment.RecurringPaymentFrequency.DAILY), - endDate = Some(now().plusDays(1)), + endDate = Some(LocalDate.now().plusDays(1)), fixedNextAmount = Some(true), nextDebitedAmount = Some(1000), nextFeesAmount = Some(100) @@ -504,7 +514,9 @@ class PaymentServiceSpec extends AnyWordSpecLike with PaymentRouteTestKit { assert(recurringPayment.nextDebitedAmount.contains(1000)) assert(recurringPayment.nextFeesAmount.contains(100)) assert(recurringPayment.numberOfRecurringPayments.getOrElse(0) == 0) - assert(recurringPayment.nextRecurringPaymentDate.exists(_.isEqual(now()))) + assert( + recurringPayment.nextRecurringPaymentDate.exists(LocalDate.now().isEqual(_)) + ) } } } @@ -537,7 +549,11 @@ class PaymentServiceSpec extends AnyWordSpecLike with PaymentRouteTestKit { assert(recurringPayment.numberOfRecurringPayments.getOrElse(0) == 1) assert(recurringPayment.cumulatedDebitedAmount.contains(0)) assert(recurringPayment.cumulatedFeesAmount.contains(0)) - assert(recurringPayment.nextRecurringPaymentDate.exists(_.isEqual(now().plusDays(1)))) + assert( + recurringPayment.nextRecurringPaymentDate.exists( + _.equals(LocalDate.now().plusDays(1).toDate) + ) + ) } } }