diff --git a/nio-provider/app/utils/DateUtils.scala b/nio-provider/app/utils/DateUtils.scala index a75b5b6..be43469 100644 --- a/nio-provider/app/utils/DateUtils.scala +++ b/nio-provider/app/utils/DateUtils.scala @@ -1,7 +1,6 @@ package utils import java.time.LocalDateTime -import org.joda.time.format.DateTimeFormat import play.api.libs.json._ import java.time.format.DateTimeFormatter diff --git a/nio-server/app/controllers/ConsentController.scala b/nio-server/app/controllers/ConsentController.scala index 21e4b52..660a59a 100644 --- a/nio-server/app/controllers/ConsentController.scala +++ b/nio-server/app/controllers/ConsentController.scala @@ -17,7 +17,7 @@ import models.ConsentFactCommand.{PatchConsentFact, UpdateConsentFact} import models.{ConsentFact, _} import utils.NioLogger import play.api.http.HttpEntity -import play.api.libs.json.{JsError, JsNull, JsValue, Json} +import play.api.libs.json.{JsError, JsNull, JsValue, Json, OFormat} import play.api.libs.streams.Accumulator import play.api.mvc._ import reactivemongo.api.Cursor @@ -277,7 +277,7 @@ class ConsentController( def ndJson(implicit ec: ExecutionContext): BodyParser[Source[JsValue, _]] = BodyParser(_ => Accumulator.source[ByteString].map(s => Right(s.via(toJson)))(ec)) object ImportError { - implicit val format = Json.format[ImportError] + implicit val format: OFormat[ImportError] = Json.format[ImportError] } case class ImportError(message: String, detailedError: JsValue = JsNull, command: JsValue = JsNull) object ImportResult { diff --git a/nio-server/test/controllers/ConsentControllerSpec.scala b/nio-server/test/controllers/ConsentControllerSpec.scala index d5f39c0..67adfd0 100644 --- a/nio-server/test/controllers/ConsentControllerSpec.scala +++ b/nio-server/test/controllers/ConsentControllerSpec.scala @@ -2,13 +2,16 @@ package controllers import org.apache.pekko.japi.Option import models._ -import java.time.{LocalDateTime, Clock} + +import java.time.{Clock, LocalDateTime} import utils.NioLogger import play.api.libs.json.{JsArray, JsObject, JsValue, Json} import play.api.libs.ws.WSResponse import utils.{DateUtils, TestUtils} import play.api.test.Helpers._ +import java.time.format.DateTimeFormatter + class ConsentControllerSpec extends TestUtils { val userId1: String = "userId1" @@ -734,7 +737,7 @@ class ConsentControllerSpec extends TestUtils { } "force lastUpdate date xml" in { - val yesterday: DateTime = LocalDateTime.now(Clock.systemUTC).minusDays(1) + val yesterday: LocalDateTime = LocalDateTime.now(Clock.systemUTC).minusDays(1) val userId6 = "userId6Xml" @@ -809,7 +812,7 @@ class ConsentControllerSpec extends TestUtils { println(patchResponse.json) patchResponse.status mustBe OK - val expectedDate: DateTime = (patchResponse.json \ "lastUpdate").validate(DateUtils.utcDateTimeReads).get + val expectedDate: LocalDateTime = (patchResponse.json \ "lastUpdate").validate(DateUtils.utcDateTimeReads).get patchResponse.json mustBe user1.copy( orgKey = Some("maif"), lastUpdate = expectedDate, @@ -861,7 +864,7 @@ class ConsentControllerSpec extends TestUtils { key = "offer1", label = "offer one", version = 1, - lastUpdate = DateTime.now().minusHours(2).withMillis(0), + lastUpdate = LocalDateTime.now().minusHours(2).withNano(0), groups = Seq( ConsentGroup( key = "maifNotifs", @@ -895,7 +898,7 @@ class ConsentControllerSpec extends TestUtils { ) ) - val updatedDate = DateTime.now().minusHours(1).withMillis(0) + val updatedDate = LocalDateTime.now().minusHours(1).withNano(0) val patchConsentFact = PartialConsentFact( offers = Some(Seq( @@ -1593,9 +1596,9 @@ class ConsentControllerSpec extends TestUtils { .as[String] mustBe "offer1" (payloadOffers \ 0 \ "lastUpdate") - .as[String] mustBe today.toString("yyyy-MM-dd'T'HH:mm:ss'Z'") + .as[String] mustBe today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")) (payloadOffers \ 1 \ "lastUpdate") - .as[String] mustBe yesterday.toString("yyyy-MM-dd'T'HH:mm:ss'Z'") + .as[String] mustBe yesterday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")) } } diff --git a/nio-server/test/controllers/OrganisationControllerSpec.scala b/nio-server/test/controllers/OrganisationControllerSpec.scala index 424ce10..bc29b42 100644 --- a/nio-server/test/controllers/OrganisationControllerSpec.scala +++ b/nio-server/test/controllers/OrganisationControllerSpec.scala @@ -103,7 +103,7 @@ class OrganisationControllerSpec extends TestUtils { (value \ "version" \ "latest").as[Boolean] mustBe org1.version.latest (value \ "version" \ "neverReleased").asOpt[Boolean] mustBe None (value \ "version" \ "lastUpdate").asOpt[String].map { s => - val lastUpdate = DateTime.parse(s) + val lastUpdate = LocalDateTime.parse(s) lastUpdate.isAfter(beforeNewOrgCreation) && lastUpdate.isBefore(LocalDateTime.now(Clock.systemUTC).plusSeconds(1)) } mustBe Some(true) @@ -134,7 +134,7 @@ class OrganisationControllerSpec extends TestUtils { (organisations \ 1 \ "version" \ "status").as[String] mustBe "DRAFT" (organisations \ 1 \ "version" \ "num").as[Int] mustBe 1 (organisations \ 1 \ "version" \ "lastUpdate").asOpt[String].map { s => - val lastUpdate = DateTime.parse(s) + val lastUpdate = LocalDateTime.parse(s) lastUpdate.isAfter(beforeNewOrgCreation) && lastUpdate.isBefore(LocalDateTime.now(Clock.systemUTC).plusSeconds(1)) } mustBe Some(true) } @@ -186,7 +186,7 @@ class OrganisationControllerSpec extends TestUtils { (value \ "version" \ "status").as[String] mustBe "RELEASED" (value \ "version" \ "num").as[Int] mustBe org1.version.num (value \ "version" \ "lastUpdate").asOpt[String].map { s => - val lastUpdate = DateTime.parse(s) + val lastUpdate = LocalDateTime.parse(s) lastUpdate.isBefore(LocalDateTime.now(Clock.systemUTC).plusSeconds(1)) } mustBe Some(true) } diff --git a/nio-server/test/db/OrganisationMongoDataStoreSpec.scala b/nio-server/test/db/OrganisationMongoDataStoreSpec.scala index 04be23c..0b9117e 100644 --- a/nio-server/test/db/OrganisationMongoDataStoreSpec.scala +++ b/nio-server/test/db/OrganisationMongoDataStoreSpec.scala @@ -39,7 +39,7 @@ class OrganisationMongoDataStoreSpec extends TestUtils { draft1 <- ds.findDraftByKey(tenant, org1Key) afterInsert = LocalDateTime - .now(DateTimeZone.UTC) + .now(Clock.systemUTC()) .format(DateUtils.utcDateFormatter) _ = Thread.sleep(1000) diff --git a/nio-server/test/models/ModelValidationSpec.scala b/nio-server/test/models/ModelValidationSpec.scala index 18069bf..de99179 100644 --- a/nio-server/test/models/ModelValidationSpec.scala +++ b/nio-server/test/models/ModelValidationSpec.scala @@ -11,7 +11,7 @@ import scala.xml.Elem class ModelValidationSpec extends AnyWordSpecLike with Matchers { - val now: DateTime = LocalDateTime.now(Clock.systemUTC) + val now: LocalDateTime = LocalDateTime.now(Clock.systemUTC) "Validation ConsentFact" should { val consentFact: ConsentFact = ConsentFact(