diff --git a/.scalafmt.conf b/.scalafmt.conf index d7797c9..5ac8eb7 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version="3.5.3" +version="3.7.17" runner.dialect = "scala213" maxColumn = 180 @@ -36,4 +36,4 @@ rewrite.rules = [AsciiSortImports] verticalMultiline.atDefnSite = true verticalMultiline.newlineAfterOpenParen = true -includeNoParensInSelectChains = true \ No newline at end of file +includeNoParensInSelectChains = true diff --git a/app/Module.scala b/app/Module.scala index 269f0ab..d313e7b 100644 --- a/app/Module.scala +++ b/app/Module.scala @@ -18,8 +18,6 @@ import com.google.inject.AbstractModule import io.swagger.v3.parser.OpenAPIV3Parser import io.swagger.v3.parser.core.extensions.SwaggerParserExtension -import uk.gov.hmrc.http.HttpClient -import uk.gov.hmrc.play.bootstrap.http.DefaultHttpClient import uk.gov.hmrc.ramltools.loaders.{RamlLoader, UrlRewriter} import uk.gov.hmrc.apipublisher.connectors.OASFileLoader.{MicroserviceOASFileLocator, OASFileLocator} @@ -31,7 +29,6 @@ class Module extends AbstractModule { override def configure(): Unit = { bind(classOf[UrlRewriter]).to(classOf[DocumentationUrlRewriter]) bind(classOf[RamlLoader]).to(classOf[DocumentationRamlLoader]) - bind(classOf[HttpClient]).to(classOf[DefaultHttpClient]) bind(classOf[SwaggerParserExtension]).toInstance(new OpenAPIV3Parser) bind(classOf[OASFileLocator]).toInstance(MicroserviceOASFileLocator) bind(classOf[OasVersionDefinitionService.OasParser]).toInstance(new OasParserImpl) diff --git a/app/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnector.scala b/app/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnector.scala index 442c598..6b2795c 100644 --- a/app/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnector.scala +++ b/app/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnector.scala @@ -22,27 +22,34 @@ import scala.concurrent.{ExecutionContext, Future} import play.api.http.Status.{BAD_REQUEST, UNPROCESSABLE_ENTITY} import play.api.libs.json.{JsObject, JsString, JsValue, Json} import uk.gov.hmrc.http.HttpReads.Implicits._ -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, HttpResponse, UnprocessableEntityException, UpstreamErrorResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, HttpResponse, StringContextOps, UnprocessableEntityException, UpstreamErrorResponse} import uk.gov.hmrc.apipublisher.util.ApplicationLogger @Singleton -class APIDefinitionConnector @Inject() (config: ApiDefinitionConfig, http: HttpClient)(implicit val ec: ExecutionContext) +class APIDefinitionConnector @Inject() (config: ApiDefinitionConfig, http: HttpClientV2)(implicit val ec: ExecutionContext) extends ConnectorRecovery with ApplicationLogger { lazy val serviceBaseUrl = config.baseUrl def publishAPI(api: JsObject)(implicit hc: HeaderCarrier): Future[Unit] = { - http.POST[JsObject, Either[UpstreamErrorResponse, HttpResponse]](s"$serviceBaseUrl/api-definition", api, Seq.empty).map { - case Right(_) => (()) - case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => throw new UnprocessableEntityException(message) - case Left(err) => throw err - } + http.post(url"$serviceBaseUrl/api-definition") + .withBody(Json.toJson(api)) + .execute[Either[UpstreamErrorResponse, HttpResponse]] + .map { + case Right(_) => (()) + case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => throw new UnprocessableEntityException(message) + case Left(err) => throw err + } } def validateAPIDefinition(definition: JsObject)(implicit hc: HeaderCarrier): Future[Option[JsValue]] = { - val url = s"$serviceBaseUrl/api-definition/validate" - http.POST[JsObject, Either[UpstreamErrorResponse, HttpResponse]](url, definition ++ Json.obj("serviceBaseUrl" -> "dummy", "serviceName" -> "dummy")) + val url = url"$serviceBaseUrl/api-definition/validate" + http + .post(url) + .withBody(definition ++ Json.obj("serviceBaseUrl" -> "dummy", "serviceName" -> "dummy")) + .execute[Either[UpstreamErrorResponse, HttpResponse]] .map { case Right(_) => None case Left(UpstreamErrorResponse(message, BAD_REQUEST, _, _)) => diff --git a/app/uk/gov/hmrc/apipublisher/connectors/APIScopeConnector.scala b/app/uk/gov/hmrc/apipublisher/connectors/APIScopeConnector.scala index 5fef1cb..d281d6e 100644 --- a/app/uk/gov/hmrc/apipublisher/connectors/APIScopeConnector.scala +++ b/app/uk/gov/hmrc/apipublisher/connectors/APIScopeConnector.scala @@ -20,30 +20,37 @@ import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import play.api.http.Status.{BAD_REQUEST, UNPROCESSABLE_ENTITY} -import play.api.libs.json.{JsString, JsValue} +import play.api.libs.json.{JsString, JsValue, Json} import uk.gov.hmrc.http.HttpReads.Implicits._ import uk.gov.hmrc.http._ +import uk.gov.hmrc.http.client.HttpClientV2 import uk.gov.hmrc.apipublisher.models.Scope import uk.gov.hmrc.apipublisher.util.ApplicationLogger @Singleton -class APIScopeConnector @Inject() (config: ApiScopeConfig, http: HttpClient)(implicit val ec: ExecutionContext) +class APIScopeConnector @Inject() (config: ApiScopeConfig, http: HttpClientV2)(implicit val ec: ExecutionContext) extends ConnectorRecovery with ApplicationLogger { lazy val serviceBaseUrl = config.baseUrl def publishScopes(scopes: JsValue)(implicit hc: HeaderCarrier): Future[Unit] = { - http.POST[JsValue, Either[UpstreamErrorResponse, HttpResponse]](s"$serviceBaseUrl/scope", scopes).map { - case Right(_) => (()) - case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => throw new UnprocessableEntityException(message) - case Left(err) => throw err - } + http + .post(url"$serviceBaseUrl/scope") + .withBody(scopes) + .execute[Either[UpstreamErrorResponse, HttpResponse]] + .map { + case Right(_) => (()) + case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => throw new UnprocessableEntityException(message) + case Left(err) => throw err + } } def validateScopes(scopes: JsValue)(implicit hc: HeaderCarrier): Future[Option[JsValue]] = { - val url = s"$serviceBaseUrl/scope/validate" - http.POST[JsValue, Either[UpstreamErrorResponse, HttpResponse]](url, scopes) + val url = url"$serviceBaseUrl/scope/validate" + http.post(url) + .withBody(Json.toJson(scopes)) + .execute[Either[UpstreamErrorResponse, HttpResponse]] .map { case Right(_) => None case Left(UpstreamErrorResponse(message, BAD_REQUEST, _, _)) => @@ -54,8 +61,7 @@ class APIScopeConnector @Inject() (config: ApiScopeConfig, http: HttpClient)(imp } def retrieveScopes(scopeKeys: Set[String])(implicit hc: HeaderCarrier): Future[Seq[Scope]] = { - val url = url"$serviceBaseUrl/scope?keys=${scopeKeys.mkString(" ")}" - http.GET[Seq[Scope]](url) + http.get(url"$serviceBaseUrl/scope?keys=${scopeKeys.mkString(" ")}").execute[Seq[Scope]] } } diff --git a/app/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnector.scala b/app/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnector.scala index 9ba1838..8899473 100644 --- a/app/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnector.scala +++ b/app/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnector.scala @@ -16,20 +16,19 @@ package uk.gov.hmrc.apipublisher.connectors -import java.net.URLEncoder -import java.nio.charset.StandardCharsets import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import play.api.http.Status.{BAD_REQUEST, UNPROCESSABLE_ENTITY} -import play.api.libs.json.{JsString, JsValue} +import play.api.libs.json.{JsString, JsValue, Json} import uk.gov.hmrc.http.HttpReads.Implicits._ -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, HttpResponse, UnprocessableEntityException, UpstreamErrorResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, HttpResponse, StringContextOps, UnprocessableEntityException, UpstreamErrorResponse} import uk.gov.hmrc.apipublisher.models.{ApiFieldDefinitions, ApiSubscriptionFieldDefinitionsRequest, FieldDefinition} @Singleton -class APISubscriptionFieldsConnector @Inject() (config: ApiSSubscriptionFieldsConfig, http: HttpClient)(implicit val ec: ExecutionContext) +class APISubscriptionFieldsConnector @Inject() (config: ApiSSubscriptionFieldsConfig, http: HttpClientV2)(implicit val ec: ExecutionContext) extends ConnectorRecovery { lazy val serviceBaseUrl = config.baseUrl @@ -37,10 +36,13 @@ class APISubscriptionFieldsConnector @Inject() (config: ApiSSubscriptionFieldsCo def publishFieldDefinitions(apiFieldDefinitions: Seq[ApiFieldDefinitions])(implicit hc: HeaderCarrier): Future[Unit] = { val putFutures: Iterable[Future[Unit]] = apiFieldDefinitions.map { case ApiFieldDefinitions(apiContext, apiVersion, fieldDefinitions) => - val urlEncodedApiContext = URLEncoder.encode(apiContext, StandardCharsets.UTF_8.name) - val request = ApiSubscriptionFieldDefinitionsRequest(fieldDefinitions) - val putUrl = s"$serviceBaseUrl/definition/context/$urlEncodedApiContext/version/$apiVersion" - http.PUT[ApiSubscriptionFieldDefinitionsRequest, Either[UpstreamErrorResponse, HttpResponse]](putUrl, request) + http.put(url"$serviceBaseUrl/definition/context/$apiContext/version/$apiVersion") + .withBody( + Json.toJson( + ApiSubscriptionFieldDefinitionsRequest(fieldDefinitions) + ) + ) + .execute[Either[UpstreamErrorResponse, HttpResponse]] .map { case Right(_) => (()) case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => throw new UnprocessableEntityException(message) @@ -55,10 +57,14 @@ class APISubscriptionFieldsConnector @Inject() (config: ApiSSubscriptionFieldsCo if (fieldDefinitions.isEmpty) { Future.successful(None) } else { - val request = ApiSubscriptionFieldDefinitionsRequest(fieldDefinitions) - val putUrl = s"$serviceBaseUrl/validate" - - http.POST[ApiSubscriptionFieldDefinitionsRequest, Either[UpstreamErrorResponse, HttpResponse]](putUrl, request) + http + .post(url"$serviceBaseUrl/validate") + .withBody( + Json.toJson( + ApiSubscriptionFieldDefinitionsRequest(fieldDefinitions) + ) + ) + .execute[Either[UpstreamErrorResponse, HttpResponse]] .map { case Right(_) => None case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => Some(JsString("Field definitions are invalid")) diff --git a/app/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnector.scala b/app/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnector.scala index 41351df..c4f1926 100644 --- a/app/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnector.scala +++ b/app/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnector.scala @@ -33,7 +33,8 @@ import play.api.Environment import play.api.http.Status.NO_CONTENT import play.api.libs.json.Json import uk.gov.hmrc.http.HttpReads.Implicits._ -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, HttpReads, HttpReadsOption, HttpResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, HttpReads, HttpReadsOption, HttpResponse, StringContextOps} import uk.gov.hmrc.ramltools.RAML import uk.gov.hmrc.ramltools.loaders.RamlLoader @@ -50,7 +51,7 @@ class MicroserviceConnector @Inject() ( config: MicroserviceConnector.Config, ramlLoader: RamlLoader, oasFileLoader: OASFileLoader, - http: HttpClient, + http: HttpClientV2, env: Environment )(implicit val ec: ExecutionContext ) extends ConnectorRecovery with HttpReadsOption with ApplicationLogger { @@ -76,15 +77,14 @@ class MicroserviceConnector @Inject() ( import uk.gov.hmrc.http.UpstreamErrorResponse - val url = s"${serviceLocation.serviceUrl}/api/definition" - - http.GET[Option[ApiAndScopes]](url)(readOptionOfNotFound, implicitly, implicitly) + http + .get(url"${serviceLocation.serviceUrl}/api/definition") + .execute[Either[UpstreamErrorResponse, Option[ApiAndScopes]]] // Uses readOptionOfNotFound for reading .map { - _.toRight(DefinitionFileNoBodyReturned(serviceLocation)) - } - .recover { - case UpstreamErrorResponse(_, NOT_FOUND, _, _) => Left(DefinitionFileNotFound(serviceLocation)) - case UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _) => Left(DefinitionFileUnprocessableEntity(serviceLocation, message)) + case Right(oApiAndScopes) => oApiAndScopes.toRight(DefinitionFileNoBodyReturned(serviceLocation)) + case Left(UpstreamErrorResponse(_, NOT_FOUND, _, _)) => Left(DefinitionFileNotFound(serviceLocation)) + case Left(UpstreamErrorResponse(message, UNPROCESSABLE_ENTITY, _, _)) => Left(DefinitionFileUnprocessableEntity(serviceLocation, message)) + case Left(err) => throw err } .map(_.map(defaultCategories)) .map(_.flatMap(validateApiAndScopesAgainstSchema)) diff --git a/build.sbt b/build.sbt index 7b15fdc..33ef40c 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,9 @@ -import play.sbt.PlayScala import uk.gov.hmrc.DefaultBuildSettings -import uk.gov.hmrc.DefaultBuildSettings._ lazy val appName = "api-publisher" -lazy val playSettings: Seq[Setting[_]] = Seq.empty +Global / bloopAggregateSourceDependencies := true +Global / bloopExportJarClassifiers := Some(Set("sources")) ThisBuild / scalaVersion := "2.13.12" ThisBuild / majorVersion := 0 @@ -15,12 +14,8 @@ ThisBuild / semanticdbVersion := scalafixSemanticdb.revision lazy val microservice = Project(appName, file(".")) .enablePlugins(PlayScala, SbtDistributablesPlugin) .disablePlugins(JUnitXmlReportPlugin) - .settings(playSettings: _*) - .settings(scalaSettings: _*) - .settings(defaultSettings(): _*) .settings(ScoverageSettings()) .settings( - name := appName, libraryDependencies ++= AppDependencies(), retrieveManaged := true, Compile / unmanagedResourceDirectories += baseDirectory.value / "app" / "resources" @@ -29,17 +24,14 @@ lazy val microservice = Project(appName, file(".")) Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-eT"), Test / fork := false, Test / parallelExecution := false, - Test / unmanagedSourceDirectories += baseDirectory.value / "test", Test / unmanagedSourceDirectories += baseDirectory.value / "testcommon", Test / unmanagedResourceDirectories += baseDirectory.value / "test" / "resources", - addTestReportOption(Test, "test-reports") ) .settings( scalacOptions ++= Seq( - "-Wconf:cat=unused&src=views/.*\\.scala:s", - "-Wconf:cat=unused&src=.*RoutesPrefix\\.scala:s", - "-Wconf:cat=unused&src=.*Routes\\.scala:s", - "-Wconf:cat=unused&src=.*ReverseRoutes\\.scala:s" + // https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html + // suppress warnings in generated routes files + "-Wconf:src=routes/.*:s" ) ) @@ -50,12 +42,9 @@ lazy val it = (project in file("it")) .settings(DefaultBuildSettings.itSettings()) .settings( name := "integration-tests", - headerSettings(Test) ++ automateHeaderSettings(Test) ) -Global / bloopAggregateSourceDependencies := true -Global / bloopExportJarClassifiers := Some(Set("sources")) commands ++= Seq( diff --git a/conf/application-json-logger.xml b/conf/application-json-logger.xml deleted file mode 100644 index bf5dd5f..0000000 --- a/conf/application-json-logger.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/conf/application.conf b/conf/application.conf index 808565a..481556c 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -26,8 +26,8 @@ play.http.errorHandler = "uk.gov.hmrc.apipublisher.wiring.ErrorHandler" # Define additional modules used here play.modules.enabled += "uk.gov.hmrc.apipublisher.config.ConfigurationModule" - play.modules.enabled += "uk.gov.hmrc.mongo.play.PlayMongoModule" +play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientV2Module" # Session Timeout # ~~~~ diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index f87677b..f9cea2a 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -3,9 +3,9 @@ import sbt._ object AppDependencies { def apply(): Seq[ModuleID] = dependencies ++ testDependencies - lazy val bootstrapVersion = "8.4.0" - lazy val mongoVersion = "1.7.0" - val commonDomainVersion = "0.13.0" + lazy val bootstrapVersion = "9.1.0" + lazy val mongoVersion = "2.1.0" + val commonDomainVersion = "0.15.0" private lazy val dependencies = Seq( "uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapVersion, diff --git a/project/plugins.sbt b/project/plugins.sbt index e2f6423..4db5d38 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,14 @@ -resolvers += "HMRC-open-artefacts-maven-2" at "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) +resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2") +resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns) +resolvers += Resolver.typesafeRepo("releases") -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.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-bloop" % "1.5.13") -addSbtPlugin("ch.epfl.scala" %% "sbt-scalafix" % "0.11.1") +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.4") +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-bloop" % "1.5.15") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1") ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always diff --git a/test/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnectorSpec.scala b/test/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnectorSpec.scala index 7ac0e44..127ca27 100644 --- a/test/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnectorSpec.scala +++ b/test/uk/gov/hmrc/apipublisher/connectors/APIDefinitionConnectorSpec.scala @@ -31,8 +31,9 @@ import utils.AsyncHmrcSpec import play.api.Configuration import play.api.libs.json.{JsObject, Json} import play.api.test.Helpers.{CONTENT_TYPE, JSON, _} +import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.http.HeaderNames.xRequestId -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient} +import uk.gov.hmrc.http.client.HttpClientV2 class APIDefinitionConnectorSpec extends AsyncHmrcSpec with BeforeAndAfterAll with GuiceOneAppPerSuite { @@ -52,7 +53,7 @@ class APIDefinitionConnectorSpec extends AsyncHmrcSpec with BeforeAndAfterAll wi val appConfig: Configuration = mock[Configuration] - val connector = new APIDefinitionConnector(apiDefinitionConfig, app.injector.instanceOf[HttpClient]) + val connector = new APIDefinitionConnector(apiDefinitionConfig, app.injector.instanceOf[HttpClientV2]) } override def beforeAll(): Unit = { diff --git a/test/uk/gov/hmrc/apipublisher/connectors/APIScopeConnectorSpec.scala b/test/uk/gov/hmrc/apipublisher/connectors/APIScopeConnectorSpec.scala index 1365a20..1e84560 100644 --- a/test/uk/gov/hmrc/apipublisher/connectors/APIScopeConnectorSpec.scala +++ b/test/uk/gov/hmrc/apipublisher/connectors/APIScopeConnectorSpec.scala @@ -30,7 +30,8 @@ import utils.AsyncHmrcSpec import play.api.libs.json.Json import play.api.test.Helpers._ import uk.gov.hmrc.http.HeaderNames.xRequestId -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, UpstreamErrorResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, UpstreamErrorResponse} import uk.gov.hmrc.apipublisher.models.Scope @@ -50,7 +51,7 @@ class APIScopeConnectorSpec extends AsyncHmrcSpec with BeforeAndAfterAll with Gu implicit val hc: HeaderCarrier = HeaderCarrier().withExtraHeaders(xRequestId -> "requestId") - val connector = new APIScopeConnector(apiScopeConfig, app.injector.instanceOf[HttpClient]) + val connector = new APIScopeConnector(apiScopeConfig, app.injector.instanceOf[HttpClientV2]) } override def beforeAll(): Unit = { diff --git a/test/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnectorSpec.scala b/test/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnectorSpec.scala index fbad468..4f50cad 100644 --- a/test/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnectorSpec.scala +++ b/test/uk/gov/hmrc/apipublisher/connectors/APISubscriptionFieldsConnectorSpec.scala @@ -33,7 +33,8 @@ import play.api.Configuration import play.api.libs.json.Json import play.api.test.Helpers._ import uk.gov.hmrc.http.HeaderNames.xRequestId -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, UpstreamErrorResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, UpstreamErrorResponse} import uk.gov.hmrc.apipublisher.models import uk.gov.hmrc.apipublisher.models.{ApiFieldDefinitions, FieldDefinition} @@ -70,7 +71,7 @@ class APISubscriptionFieldsConnectorSpec extends AsyncHmrcSpec with BeforeAndAft val appConfig: Configuration = mock[Configuration] - val connector = new APISubscriptionFieldsConnector(apiSubscriptionFieldsConfig, app.injector.instanceOf[HttpClient]) + val connector = new APISubscriptionFieldsConnector(apiSubscriptionFieldsConfig, app.injector.instanceOf[HttpClientV2]) def publishFieldDefinitions(definitions: Seq[ApiFieldDefinitions] = apiFieldDefinitions): Future[Unit] = connector.publishFieldDefinitions(definitions) diff --git a/test/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnectorSpec.scala b/test/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnectorSpec.scala index bb96cff..5407d80 100644 --- a/test/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnectorSpec.scala +++ b/test/uk/gov/hmrc/apipublisher/connectors/MicroserviceConnectorSpec.scala @@ -36,7 +36,8 @@ import play.api.libs.json.{JsArray, JsObject, Json} import play.api.test.Helpers._ import play.api.{Configuration, Environment} import uk.gov.hmrc.http.HeaderNames.xRequestId -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, UpstreamErrorResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, UpstreamErrorResponse} import uk.gov.hmrc.apipublisher.models.APICategory.{CUSTOMS, EXAMPLE, OTHER} import uk.gov.hmrc.apipublisher.models._ @@ -73,7 +74,7 @@ class MicroserviceConnectorSpec extends AsyncHmrcSpec with BeforeAndAfterAll wit MicroserviceConnector.Config(validateApiDefinition = true, oasParserMaxDuration = 3.seconds), mockRamlLoader, mockOasFileLoader, - app.injector.instanceOf[HttpClient], + app.injector.instanceOf[HttpClientV2], app.injector.instanceOf[Environment] ) @@ -87,7 +88,7 @@ class MicroserviceConnectorSpec extends AsyncHmrcSpec with BeforeAndAfterAll wit MicroserviceConnector.Config(validateApiDefinition = false, oasParserMaxDuration = 3.seconds), mockRamlLoader, mockOasFileLoader, - app.injector.instanceOf[HttpClient], + app.injector.instanceOf[HttpClientV2], app.injector.instanceOf[Environment] ) } @@ -99,7 +100,7 @@ class MicroserviceConnectorSpec extends AsyncHmrcSpec with BeforeAndAfterAll wit MicroserviceConnector.Config(validateApiDefinition = true, oasParserMaxDuration = 3.seconds), mockRamlLoader, mockOasFileLoader, - app.injector.instanceOf[HttpClient], + app.injector.instanceOf[HttpClientV2], app.injector.instanceOf[Environment] ) }