Skip to content

Commit

Permalink
DDCE-5806 - Updating bootstrap play version (#209)
Browse files Browse the repository at this point in the history
* DDCE-5806 - Updating bootstrap play version

* DDCE-5806 - Updating test case to support HttpClientV2

* DDCE-5806 - Updating test case to support HttpClientV2

* DDCE-5806 - addressing PR bot comments

* DDCE-5806 - updating dependencies
  • Loading branch information
mithra-balakrishnan authored Oct 22, 2024
1 parent 211a2c1 commit bd293a9
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 104 deletions.
15 changes: 8 additions & 7 deletions app/uk/gov/hmrc/rasapi/connectors/DesConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package uk.gov.hmrc.rasapi.connectors

import play.api.Logging
import play.api.libs.json.{JsObject, JsValue, Json, Writes}
import play.api.libs.json.{JsObject, Json}
import uk.gov.hmrc.http.{HeaderCarrier, _}
import uk.gov.hmrc.play.bootstrap.http.DefaultHttpClient
import uk.gov.hmrc.play.bootstrap.http.HttpClientV2Provider
import uk.gov.hmrc.rasapi.config.AppContext
import uk.gov.hmrc.rasapi.models._
import uk.gov.hmrc.rasapi.services.AuditService
Expand All @@ -29,7 +29,7 @@ import javax.inject.Inject
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}

class DesConnector @Inject()( httpPost: DefaultHttpClient,
class DesConnector @Inject()( httpPost: HttpClientV2Provider,
val auditService: AuditService,
val appContext: AppContext,
implicit val ec: ExecutionContext) extends Logging {
Expand Down Expand Up @@ -119,10 +119,11 @@ class DesConnector @Inject()( httpPost: DefaultHttpClient,

val payload = Json.toJson(Json.toJson[IndividualDetails](member)
.as[JsObject] + ("pensionSchemeOrganisationID" -> Json.toJson(userId)))

val result = httpPost.POST[JsValue, HttpResponse](uri, payload, desHeaders)
(implicitly[Writes[IndividualDetails]], implicitly[HttpReads[HttpResponse]], rasHeaders, ec)

val result = httpPost.get()
.post(url"$uri")
.setHeader(desHeaders: _*)
.withBody(payload)
.execute[HttpResponse]
result.map(response =>
resolveResponse(response, userId, member.nino, apiVersion)
).recover {
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ majorVersion := 1
DefaultBuildSettings.defaultSettings()
PlayKeys.playDefaultPort := 9669

scalaVersion := "2.13.13"
scalaVersion := "2.13.15"
retrieveManaged := true
routesGenerator := InjectedRoutesGenerator

Expand Down
14 changes: 0 additions & 14 deletions conf/application-json-logger.xml

This file was deleted.

2 changes: 1 addition & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ play.i18n.langs=["en"]
# !!!WARNING!!! DO NOT CHANGE THIS ROUTER
play.http.router=prod.Routes

play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule"
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientV2Module"
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.AuthModule"
play.modules.enabled += "uk.gov.hmrc.mongo.play.PlayMongoModule"

Expand Down
15 changes: 8 additions & 7 deletions it/uk/gov/hmrc/rasapi/api/FileProcessingApiISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import org.scalatest.concurrent.{Eventually, ScalaFutures}
import org.scalatestplus.play.PlaySpec
import org.scalatestplus.play.guice.GuiceOneServerPerSuite
import play.api.Application
import play.api.http.Status.OK
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.libs.ws.WSClient
import play.api.test.Helpers.OK
import play.api.test.{DefaultAwaitTimeout, FutureAwaits}
import uk.gov.hmrc.http.HttpClient
import uk.gov.hmrc.http.client.HttpClientV2
import uk.gov.hmrc.http.{HeaderCarrier, StringContextOps}
import uk.gov.hmrc.rasapi.itUtils.WireMockServerHelper
import uk.gov.hmrc.rasapi.models.ResultsFile
import uk.gov.hmrc.rasapi.repository.RasFilesRepository
Expand All @@ -46,7 +47,9 @@ class FileProcessingApiISpec extends PlaySpec with ScalaFutures

lazy val rasFileRepository: RasFilesRepository = app.injector.instanceOf[RasFilesRepository]
lazy val ws: WSClient = app.injector.instanceOf[WSClient]
lazy val client:HttpClient = app.injector.instanceOf[HttpClient]
lazy val client1:HttpClientV2 = app.injector.instanceOf[HttpClientV2]
private val uri = s"http://localhost:$port/ras-api/file/getFile/reference-1"
implicit val hc : HeaderCarrier = HeaderCarrier()

class Setup(filename: String) {
val largeFile: File = new File("it/resources/testFiles/bulk.csv")
Expand All @@ -65,12 +68,10 @@ class FileProcessingApiISpec extends PlaySpec with ScalaFutures
"calling the getFile" should {
"retrieve the file" in new Setup("reference-1") {
insertFile()

val headers = Map("Authorization" -> "Bearer123")
authMocks
val response = await(client.doGet(s"http://localhost:$port/ras-api/file/getFile/reference-1", Seq(("Authorization", "Bearer123"))))

val testSource: BufferedSource = Source.fromFile("it/resources/testFiles/bulk.csv")

val response = await(client1.get(url"$uri").setHeader(headers.toSeq:_*).execute)
response.status mustBe OK
response.body mustBe testSource.getLines().toList.mkString("\n")
response.header("Content-Type") mustBe Some("application/csv")
Expand Down
12 changes: 6 additions & 6 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ import sbt.*

object AppDependencies {

val hmrcMongoVersion = "1.9.0"
val bootstrapVersion = "8.5.0"
val hmrcMongoVersion = "2.2.0"
val bootstrapVersion = "9.5.0"

val compile: Seq[ModuleID] = Seq(
ws,
"uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % hmrcMongoVersion,
"uk.gov.hmrc" %% "domain" % "8.3.0-play-28",
"uk.gov.hmrc" %% "play-hmrc-api-play-30" % "8.0.0",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.0"
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.18.0"
)

val test: Seq[ModuleID] = Seq(
"uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % hmrcMongoVersion,
"org.scalatest" %% "scalatest" % "3.2.18",
"org.scalatest" %% "scalatest" % "3.2.19",
"org.scalatestplus" %% "mockito-5-10" % "3.2.18.0",
"de.leanovate.play-mockws" %% "play-mockws-3-0" % "3.0.3",
"org.wiremock" % "wiremock-standalone" % "3.5.3",
"de.leanovate.play-mockws" %% "play-mockws-3-0" % "3.0.5",
"org.wiremock" % "wiremock-standalone" % "3.9.1",
"com.vladsch.flexmark" % "flexmark-all" % "0.64.8"
).map(_ % "it, test")

Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefact

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.22.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.2")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.5")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0" exclude("org.scala-lang.modules", "scala-xml_2.12"))
addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "2.0.11")
addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "2.2.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
Loading

0 comments on commit bd293a9

Please sign in to comment.