diff --git a/app/Module.scala b/app/Module.scala
index d0f3c06..e595083 100644
--- a/app/Module.scala
+++ b/app/Module.scala
@@ -24,7 +24,6 @@ import repositories._
import services.{ABPAddressRepositoryMetrics, NonABPAddressRepositoryMetrics, ReferenceData}
import javax.inject.Singleton
-import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{ExecutionContext, Future}
import scala.util.Try
@@ -51,9 +50,10 @@ class Module(environment: Environment, configuration: Configuration) extends Abs
@Provides
@Singleton
def provideAbpAddressRepository(metrics: Metrics, configHelper: ConfigHelper,
- rdsQueryConfig: RdsQueryConfig, executionContext: ExecutionContext,
+ rdsQueryConfig: RdsQueryConfig,
applicationLifecycle: ApplicationLifecycle,
- inMemoryABPAddressRepository: InMemoryABPAddressRepository): ABPAddressRepository = {
+ inMemoryABPAddressRepository: InMemoryABPAddressRepository)
+ (implicit executionContext: ExecutionContext) : ABPAddressRepository = {
val dbEnabled = isDbEnabled(configHelper)
val cipPaasDbEnabled = configHelper.isCipPaasDbEnabled()
@@ -75,8 +75,7 @@ class Module(environment: Environment, configuration: Configuration) extends Abs
}
@Provides
- def provideCIPPostgresConnectionTestResult(executionContext: ExecutionContext,
- applicationLifecycle: ApplicationLifecycle): Try[Future[Int]] =
+ def provideCIPPostgresConnectionTestResult(applicationLifecycle: ApplicationLifecycle)(implicit executionContext: ExecutionContext) : Try[Future[Int]] =
Try {
val transactor = new TransactorProvider(configuration, applicationLifecycle, "cip-address-lookup-rds").get(executionContext)
new CIPPostgresABPAddressRepository(transactor).testConnection
diff --git a/app/repositories/InMemoryAddressTestData.scala b/app/repositories/InMemoryAddressTestData.scala
index fb45278..02b5625 100644
--- a/app/repositories/InMemoryAddressTestData.scala
+++ b/app/repositories/InMemoryAddressTestData.scala
@@ -59,7 +59,7 @@ object InMemoryAddressTestData {
val cannedNonUKDataFile = Environment.simple().resource(cannedNonUKData).get
val splitter = new CsvLineSplitter(Source.fromURL(cannedNonUKDataFile).bufferedReader()).asScala.toSeq
splitter.map(CSV.convertNonUKCsvLine)
- }.groupBy(_._1).mapValues(_.map(_._2).toList)
+ }.groupBy(_._1).view.mapValues(_.map(_._2).toList).toMap
def dbsToFilterText(dbAddress: DbAddress): Set[String] =
(dbAddress.lines.mkString(" ") + " " + dbAddress.town + " " + dbAddress.administrativeArea.getOrElse("") + " " + dbAddress.poBox.getOrElse("") + " " + dbAddress.postcode).replaceAll("[\\p{Space},]+", " ").split(" ").map(_.toLowerCase).toSet
diff --git a/app/repositories/PostgresABPAddressRepository.scala b/app/repositories/PostgresABPAddressRepository.scala
index 33c266b..abcffc6 100644
--- a/app/repositories/PostgresABPAddressRepository.scala
+++ b/app/repositories/PostgresABPAddressRepository.scala
@@ -25,10 +25,9 @@ import model.address.{Outcode, Postcode}
import model.internal.{DbAddress, SqlDbAddress}
import javax.inject.Inject
-import scala.concurrent.ExecutionContext.Implicits.global
-import scala.concurrent.Future
+import scala.concurrent.{ExecutionContext, Future}
-class PostgresABPAddressRepository @Inject()(transactor: Transactor[IO], queryConfig: RdsQueryConfig) extends ABPAddressRepository {
+class PostgresABPAddressRepository @Inject()(transactor: Transactor[IO], queryConfig: RdsQueryConfig)(implicit ec: ExecutionContext) extends ABPAddressRepository {
import PostgresABPAddressRepository._
diff --git a/app/repositories/TransactorProvider.scala b/app/repositories/TransactorProvider.scala
index 5b1579d..a1a53c2 100644
--- a/app/repositories/TransactorProvider.scala
+++ b/app/repositories/TransactorProvider.scala
@@ -16,7 +16,7 @@
package repositories
-import cats.effect.{ContextShift, IO}
+import cats.effect.{Blocker, ContextShift, IO}
import doobie.Transactor
import doobie.hikari.HikariTransactor
import play.api.Configuration
@@ -37,8 +37,8 @@ class TransactorProvider (configuration: Configuration, applicationLifecycle: Ap
dbConfig.get[String]("url"),
dbConfig.get[String]("username"),
dbConfig.get[String]("password"),
- ExecutionContext.fromExecutor(Executors.newFixedThreadPool(10)), // waiting for connections
- ExecutionContext.fromExecutor(Executors.newCachedThreadPool()) // executing db calls, bounded by hikari connection pool size
+ ExecutionContext.fromExecutor(Executors.newFixedThreadPool(10)),
+ Blocker.liftExecutorService(Executors.newCachedThreadPool()) // executing db calls, bounded by hikari connection pool size
)
val (transactor, releaseResource) = hikariTransactorResource.allocated.unsafeRunSync()
diff --git a/app/services/ReferenceData.scala b/app/services/ReferenceData.scala
index 74d224b..23583ee 100644
--- a/app/services/ReferenceData.scala
+++ b/app/services/ReferenceData.scala
@@ -19,7 +19,6 @@ package services
import com.github.tototoshi.csv.CSVReader
import model.address.ReferenceItem
-import java.util.NoSuchElementException
import java.util.zip.GZIPInputStream
import scala.collection.mutable.ListBuffer
import scala.io.{Codec, Source}
@@ -88,7 +87,7 @@ object ReferenceData {
}
val time = System.currentTimeMillis() - start
- println(s"Loading $resource took ${time}ms")
+ // println(s"Loading $resource took ${time}ms")
outputBuffer.toMap
}
diff --git a/build.sbt b/build.sbt
index ead525b..cbddc1d 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,7 +1,7 @@
import uk.gov.hmrc.DefaultBuildSettings.{addTestReportOption, defaultSettings, scalaSettings, targetJvm}
import uk.gov.hmrc.sbtdistributables.SbtDistributablesPlugin.publishingSettings
-val thisScalaVersion = "2.12.15"
+val thisScalaVersion = "2.13.10"
lazy val root = Project("address-lookup", file("."))
.enablePlugins(play.sbt.PlayScala, SbtAutoBuildPlugin, SbtGitVersioning, SbtDistributablesPlugin)
diff --git a/conf/application-json-logger.xml b/conf/application-json-logger.xml
index 75222d7..eea14a6 100644
--- a/conf/application-json-logger.xml
+++ b/conf/application-json-logger.xml
@@ -5,9 +5,9 @@
-
+
-
+
diff --git a/conf/application.conf b/conf/application.conf
index a824b5c..5f692e6 100644
--- a/conf/application.conf
+++ b/conf/application.conf
@@ -24,21 +24,16 @@ play.http.requestHandler = "uk.gov.hmrc.play.bootstrap.http.RequestHandler"
# 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.bootstrap.AuditModule"
+play.modules.enabled += "uk.gov.hmrc.play.audit.AuditModule"
# Provides an implementation of MetricsFilter. Use `uk.gov.hmrc.play.bootstrap.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 backend microservice.
-play.modules.enabled += "uk.gov.hmrc.play.bootstrap.MicroserviceModule"
+play.modules.enabled += "uk.gov.hmrc.play.bootstrap.backend.BackendModule"
-play.http.filters = "uk.gov.hmrc.play.bootstrap.filters.MicroserviceFilters"
play.http.router = app.Routes
-
-#play 2.5 requires an application secret
-play.crypto.secret: "H7dVw$PlJiD)^U,oa4TA1pa]pT:4ETLqbL&2P=n6T~p,A*}^.Y46@PQOV~9(B09Hc]t7-hsf~&@w=zH"
-
play.http.errorHandler = "uk.gov.hmrc.play.bootstrap.backend.http.JsonErrorHandler"
play.ws.timeout.request = 70000ms # 70 secs
diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala
index 235a9c7..0714faa 100644
--- a/project/AppDependencies.scala
+++ b/project/AppDependencies.scala
@@ -8,17 +8,17 @@ object AppDependencies {
private val scalaTestVersion = "3.1.4"
private val pegdownVersion = "1.6.0"
- private val doobieVersion = "0.7.1"
+ private val doobieVersion = "0.13.4"
val compile = Seq(
ws,
- "uk.gov.hmrc" %% "bootstrap-backend-play-28" % "5.16.0",
+ "uk.gov.hmrc" %% "bootstrap-backend-play-28" % "7.12.0",
"com.univocity" % "univocity-parsers" % "2.9.1",
- "com.github.tototoshi" %% "scala-csv" % "1.3.8",
+ "com.github.tototoshi" %% "scala-csv" % "1.3.10",
"org.tpolecat" %% "doobie-core" % doobieVersion,
"org.tpolecat" %% "doobie-postgres" % doobieVersion,
"org.tpolecat" %% "doobie-hikari" % doobieVersion,
- jdbc
+ jdbc excludeAll ExclusionRule(organization = "org.slf4j")
)
val test = Seq(
@@ -27,7 +27,7 @@ object AppDependencies {
"org.pegdown" % "pegdown" % pegdownVersion % "test, it",
"com.typesafe.play" %% "play-test" % PlayVersion.current % "test, it",
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % "test, it",
- "org.scalatestplus" %% "mockito-3-4" % "3.1.4.0" % "test, it",
+ "org.scalatestplus" % "mockito-4-6_2.13" % "3.2.14.0" % "test, it",
"org.jsoup" % "jsoup" % "1.14.3" % "test, it",
)
diff --git a/project/build.properties b/project/build.properties
index 3161d21..563a014 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version=1.6.1
+sbt.version=1.7.2
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 2b4f158..27031af 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1,11 +1,9 @@
+resolvers += Resolver.typesafeRepo("releases")
resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)
-
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.8")
-
-addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.5.0")
-
-addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "2.4.0")
+addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.8.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.1.0")
+
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.18")
diff --git a/test/unit/controllers/AddressLookupIdControllerTest.scala b/test/unit/controllers/AddressLookupIdControllerTest.scala
index 5a20401..900ec2d 100644
--- a/test/unit/controllers/AddressLookupIdControllerTest.scala
+++ b/test/unit/controllers/AddressLookupIdControllerTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/unit/controllers/AddressSearchControllerTest.scala b/test/unit/controllers/AddressSearchControllerTest.scala
index 7ab869f..09ba3ea 100644
--- a/test/unit/controllers/AddressSearchControllerTest.scala
+++ b/test/unit/controllers/AddressSearchControllerTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ import util.Utils._
import scala.concurrent.Future
import scala.concurrent.duration._
+import scala.language.postfixOps
class AddressSearchControllerTest extends AnyWordSpec with Matchers with GuiceOneAppPerSuite with MockitoSugar {
diff --git a/test/unit/model/AddressTest.scala b/test/unit/model/AddressTest.scala
index 4a8835a..3789e80 100644
--- a/test/unit/model/AddressTest.scala
+++ b/test/unit/model/AddressTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/unit/model/RequestTest.scala b/test/unit/model/RequestTest.scala
index a64b024..fd51147 100644
--- a/test/unit/model/RequestTest.scala
+++ b/test/unit/model/RequestTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/unit/repositories/InMemoryABPAddressRepositoryTest.scala b/test/unit/repositories/InMemoryABPAddressRepositoryTest.scala
index 57a99cd..f64a284 100644
--- a/test/unit/repositories/InMemoryABPAddressRepositoryTest.scala
+++ b/test/unit/repositories/InMemoryABPAddressRepositoryTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/unit/services/ABPAddressRepositoryMetricsTest.scala b/test/unit/services/ABPAddressRepositoryMetricsTest.scala
index 7939207..f1ff94b 100644
--- a/test/unit/services/ABPAddressRepositoryMetricsTest.scala
+++ b/test/unit/services/ABPAddressRepositoryMetricsTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/unit/services/ResponseProcessorTest.scala b/test/unit/services/ResponseProcessorTest.scala
index f41f52b..dcbe904 100644
--- a/test/unit/services/ResponseProcessorTest.scala
+++ b/test/unit/services/ResponseProcessorTest.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/unit/util/utils.scala b/test/unit/util/utils.scala
index a8524b5..a4eeb7f 100644
--- a/test/unit/util/utils.scala
+++ b/test/unit/util/utils.scala
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 HM Revenue & Customs
+ * Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.