Skip to content

Commit

Permalink
APIS-6755: Upgrade to Play 3.0 (#78)
Browse files Browse the repository at this point in the history
* APIS-6755: Upgrade to Play 2.9

* APIS-6755: Upgrade to Play 3.0
  • Loading branch information
johnsgp authored Feb 2, 2024
1 parent a9c3a12 commit 54ea273
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package uk.gov.hmrc.apiplatformoutboundsoap.connectors

import javax.inject.{Inject, Singleton}

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem

import play.api.Configuration
import play.api.libs.ws.{WSClient, WSProxyServer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import java.util.concurrent.TimeUnit
import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

import akka.NotUsed
import akka.stream.alpakka.mongodb.scaladsl.MongoSource
import akka.stream.scaladsl.Source
import org.apache.pekko.NotUsed
import org.apache.pekko.stream.connectors.mongodb.scaladsl.MongoSource
import org.apache.pekko.stream.scaladsl.Source
import org.bson.codecs.configuration.CodecRegistries._
import org.mongodb.scala.ReadPreference.primaryPreferred
import org.mongodb.scala.bson.collection.immutable.Document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package uk.gov.hmrc.apiplatformoutboundsoap.scheduled

import scala.concurrent.duration.{DurationInt, FiniteDuration}
import scala.concurrent.duration.{Duration, DurationInt, FiniteDuration}
import scala.concurrent.{ExecutionContext, Future}

import org.joda.time.Duration

import uk.gov.hmrc.mongo.lock.{LockService, MongoLockRepository}

trait LockedScheduledJob {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package uk.gov.hmrc.apiplatformoutboundsoap.scheduled
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

import akka.actor.Cancellable
import org.apache.commons.lang3.time.StopWatch
import org.apache.pekko.actor.{Cancellable, Scheduler}

import play.api.inject.ApplicationLifecycle
import play.api.{Application, Logging}
Expand All @@ -30,7 +30,7 @@ import play.api.{Application, Logging}
trait RunningOfScheduledJobs extends Logging {

implicit val ec: ExecutionContext
lazy val scheduler: akka.actor.Scheduler = application.actorSystem.scheduler
lazy val scheduler: Scheduler = application.actorSystem.scheduler
val application: Application
val scheduledJobs: Seq[LockedScheduledJob]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
package uk.gov.hmrc.apiplatformoutboundsoap.scheduled

import javax.inject.{Inject, Singleton}
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.duration.{Duration, FiniteDuration}
import scala.concurrent.{ExecutionContext, Future}

import org.joda.time.Duration

import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.mongo.lock.MongoLockRepository

Expand All @@ -31,7 +29,7 @@ import uk.gov.hmrc.apiplatformoutboundsoap.services.OutboundService
@Singleton
class SoapMessageRetryJob @Inject() (appConfig: AppConfig, override val lockRepository: MongoLockRepository, outboundService: OutboundService)
extends LockedScheduledJob {
override val releaseLockAfter: Duration = Duration.standardSeconds(appConfig.retryJobLockDuration.toSeconds)
override val releaseLockAfter: Duration = appConfig.retryJobLockDuration

override def name: String = "SoapMessageRetryJob"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import javax.xml.namespace.QName
import scala.concurrent.{ExecutionContext, Future}
import scala.jdk.CollectionConverters._

import akka.Done
import akka.stream.Materializer
import akka.stream.scaladsl.Sink
import org.apache.axiom.om.OMAbstractFactory.{getOMFactory, getSOAP12Factory}
import org.apache.axiom.om._
import org.apache.axiom.om.util.AXIOMUtil.stringToOM
import org.apache.axiom.soap.SOAPEnvelope
import org.apache.axis2.addressing.AddressingConstants.Final.{WSAW_NAMESPACE, WSA_NAMESPACE}
import org.apache.axis2.addressing.AddressingConstants._
import org.apache.axis2.wsdl.WSDLUtil
import org.apache.pekko.Done
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.Sink

import play.api.Logging
import play.api.cache.AsyncCacheApi
Expand Down
45 changes: 0 additions & 45 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,8 @@ include "backend.conf"

appName = api-platform-outbound-soap

# An ApplicationLoader that uses Guice to bootstrap the application.
play.application.loader = "uk.gov.hmrc.play.bootstrap.ApplicationLoader"

# Primary entry point for all HTTP requests on Play applications
play.http.requestHandler = "uk.gov.hmrc.play.bootstrap.http.RequestHandler"

# Setting this as a first module to allow the other modules to use the play built in injector properly.
play.modules.enabled += "uk.gov.hmrc.apiplatformoutboundsoap.config.InjectionModule"
# Provides an implementation of AuditConnector. Use `uk.gov.hmrc.play.bootstrap.AuditModule` or create your own.
# An audit connector must be provided.
play.modules.enabled += "uk.gov.hmrc.play.audit.AuditModule"

# Provides an implementation of MetricsFilter. Use `uk.gov.hmrc.play.graphite.GraphiteMetricsModule` or create your own.
# A metric filter must be provided
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.graphite.GraphiteMetricsModule"

# Provides an implementation and configures all filters required by a Platform frontend microservice.
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.backend.BackendModule"

# Default http client
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule"
Expand Down Expand Up @@ -77,28 +61,8 @@ controllers {
confidenceLevel = 300
}

# Metrics plugin settings - graphite reporting is configured on a per env basis
metrics {
name = ${appName}
rateUnit = SECONDS
durationUnit = SECONDS
showSamples = true
jvm = true
enabled = true
}

# Microservice specific config

auditing {
enabled = true
consumer {
baseUri {
host = localhost
port = 8100
}
}
}

mongodb {
uri = "mongodb://localhost:27017/api-platform-outbound-soap"
}
Expand All @@ -113,15 +77,6 @@ cryptoKeystoreLocation = "KeyStore.jks"
enableMessageSigning = false

microservice {
metrics {
graphite {
host = graphite
port = 2003
prefix = play.${appName}.
enabled = false
}
}

services {
auth {
host = localhost
Expand Down
2 changes: 0 additions & 2 deletions conf/prod.routes
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Add all the application routes to the app.routes file
-> / app.Routes
-> / health.Routes

GET /admin/metrics com.kenshoo.play.metrics.MetricsController.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import java.time.temporal.ChronoUnit
import java.time.{Duration, Instant}
import java.util.UUID.randomUUID

import akka.stream.Materializer
import akka.stream.scaladsl.Sink
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.Sink
import org.mongodb.scala.MongoWriteException
import org.mongodb.scala.ReadPreference.primaryPreferred
import org.mongodb.scala.bson.BsonBoolean
Expand Down
18 changes: 6 additions & 12 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import play.core.PlayVersion.current
import play.sbt.PlayImport.caffeine
import sbt._

object AppDependencies {
val bootstrapPlayVersion = "7.12.0"
val bootstrapPlayVersion = "8.4.0"
val mongoVersion = "1.7.0"

val compile = Seq(
"uk.gov.hmrc" %% "bootstrap-backend-play-28" % bootstrapPlayVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-28" % mongoVersion,
"com.typesafe.play" %% "play-json-joda" % "2.9.2",
"com.lightbend.akka" %% "akka-stream-alpakka-mongodb" % "3.0.4",
"uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapPlayVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % mongoVersion,
"org.apache.pekko" %% "pekko-connectors-mongodb" % "1.0.2",
"org.apache.axis2" % "axis2-kernel" % "1.8.0",
"org.apache.wss4j" % "wss4j-ws-security-dom" % "2.4.1",
caffeine
)

val test = Seq(
"uk.gov.hmrc" %% "bootstrap-test-play-28" % bootstrapPlayVersion % "test, it",
"com.typesafe.play" %% "play-test" % current % "test, it",
"uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion % "test, it",
"org.mockito" %% "mockito-scala-scalatest" % "1.17.29" % "test, it",
"org.scalatest" %% "scalatest" % "3.2.17" % "test, it",
"com.vladsch.flexmark" % "flexmark-all" % "0.62.2" % "test, it",
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % "test, it",
"org.xmlunit" % "xmlunit-core" % "2.9.0" % "test, it",
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-28" % mongoVersion % "it"
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % mongoVersion % "it"
)

val axiomVersion = "1.4.0"
Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ resolvers ++= Seq(
resolvers += Resolver.typesafeRepo("releases")

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.4.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.21")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")

addDependencyTreePlugin

ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.apiplatformoutboundsoap.connectors

import akka.actor.ActorSystem
import org.apache.pekko.actor.ActorSystem
import org.scalatest.OptionValues
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.xml.{Elem, NodeSeq, XML}

import akka.stream.Materializer
import org.apache.pekko.stream.Materializer
import org.mockito.{ArgumentCaptor, ArgumentMatchersSugar, MockitoSugar}
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.Future.{failed, successful}

import akka.stream.Materializer
import org.apache.pekko.stream.Materializer
import org.mockito.captor.{ArgCaptor, Captor}
import org.mockito.scalatest.ResetMocksAfterEachTest
import org.mockito.{ArgumentCaptor, ArgumentMatchersSugar, MockitoSugar}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future.{failed, successful}
import scala.concurrent.duration.Duration

import akka.Done
import org.apache.pekko.Done
import org.mockito.{ArgumentMatchersSugar, MockitoSugar}
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future.successful
import scala.xml.Elem

import akka.stream.Materializer
import org.joda.time.DateTime
import org.joda.time.DateTimeZone.UTC
import org.apache.pekko.stream.Materializer
import org.mockito.{ArgumentMatchersSugar, MockitoSugar}
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down Expand Up @@ -53,8 +51,7 @@ class ConfirmationServiceSpec extends AnyWordSpec with Matchers with GuiceOneApp
val appConfigMock: AppConfig = mock[AppConfig]
val httpStatus: Int = 200

val expectedCreateDateTime: DateTime = DateTime.now(UTC)
val expectedGlobalId: UUID = UUID.randomUUID
val expectedGlobalId: UUID = UUID.randomUUID

val underTest: ConfirmationService =
new ConfirmationService(outboundMessageRepository = outboundMessageRepositoryMock, notificationCallbackConnector = notificationCallbackConnectorMock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import scala.concurrent.Future
import scala.concurrent.Future.successful
import scala.concurrent.duration.Duration

import akka.stream.Materializer
import akka.stream.scaladsl.Source.{fromIterator, single}
import com.mongodb.client.result.InsertOneResult
import org.apache.axiom.soap.SOAPEnvelope
import org.apache.pekko.stream.Materializer
import org.apache.pekko.stream.scaladsl.Source.{fromIterator, single}
import org.mockito.{ArgumentCaptor, ArgumentMatchersSugar, MockitoSugar}
import org.mongodb.scala.bson.BsonNumber
import org.scalatest.matchers.should.Matchers
Expand Down

0 comments on commit 54ea273

Please sign in to comment.