Skip to content

Commit

Permalink
Move to play 3 / pekko
Browse files Browse the repository at this point in the history
  • Loading branch information
larousso committed Oct 4, 2024
1 parent 0e29015 commit 67852f8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion nio-provider/app/utils/DateUtils.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions nio-server/app/controllers/ConsentController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
17 changes: 10 additions & 7 deletions nio-server/test/controllers/ConsentControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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'"))

}
}
Expand Down
6 changes: 3 additions & 3 deletions nio-server/test/controllers/OrganisationControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion nio-server/test/db/OrganisationMongoDataStoreSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion nio-server/test/models/ModelValidationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 67852f8

Please sign in to comment.