From 7c666d7acea3eec367bfc29d593b13efc2f89190 Mon Sep 17 00:00:00 2001 From: Richard Melvin <40235254+r-melvin@users.noreply.github.com> Date: Wed, 21 Nov 2018 11:10:33 +0000 Subject: [PATCH] Revert "Sar 2859 - migrating to play 2.6" --- app/config/MicroserviceAppConfig.scala | 28 ++++++------- .../PaperlessPreferenceController.scala | 12 +++--- .../matching/LockoutStatusController.scala | 8 ++-- .../subscription/SubscriptionController.scala | 14 +++---- .../SubscriptionStatusController.scala | 17 +++----- .../FeatureSwitchController.scala | 12 +++--- .../ResetAgentLockoutController.scala | 9 ++--- build.sbt | 4 +- .../PaperlessPreferenceControllerISpec.scala | 3 +- .../LockoutStatusControllerISpec.scala | 2 +- it/helpers/ComponentSpecBase.scala | 2 +- it/helpers/WiremockHelper.scala | 2 +- it/helpers/servicemocks/WireMockMethods.scala | 6 +-- project/MicroServiceBuild.scala | 39 ++++++------------- project/plugins.sbt | 6 +-- .../mocks/TestBusinessDetailsConnector.scala | 2 + .../mocks/TestRegistrationConnector.scala | 2 +- .../mocks/TestSubscriptionConnector.scala | 2 +- .../PaperlessPreferenceControllerSpec.scala | 5 +-- .../LockoutStatusControllerSpec.scala | 2 +- .../SubscriptionControllerSpec.scala | 3 +- .../SubscriptionStatusControllerSpec.scala | 7 ++-- .../mocks/TestSubscriptionService.scala | 2 +- 23 files changed, 86 insertions(+), 103 deletions(-) diff --git a/app/config/MicroserviceAppConfig.scala b/app/config/MicroserviceAppConfig.scala index 2f619b09..40802073 100644 --- a/app/config/MicroserviceAppConfig.scala +++ b/app/config/MicroserviceAppConfig.scala @@ -16,33 +16,34 @@ package config -import config.featureswitch.FeatureSwitching import javax.inject.{Inject, Singleton} -import play.api.Configuration -import uk.gov.hmrc.play.bootstrap.config.ServicesConfig + +import config.featureswitch.FeatureSwitching +import play.api.{Application, Configuration} +import uk.gov.hmrc.play.config.ServicesConfig trait AppConfig { val authURL: String val ggURL: String val ggAdminURL: String val ggAuthenticationURL: String - def desURL: String - val desEnvironment: String val desToken: String val paperlessPreferencesExpirySeconds: Int } @Singleton -class MicroserviceAppConfig @Inject()(servicesConfig: ServicesConfig, configuration: Configuration) extends AppConfig with FeatureSwitching { +class MicroserviceAppConfig @Inject()(val app: Application) extends AppConfig with ServicesConfig with FeatureSwitching { + val configuration = app.configuration + override val mode = app.mode - private def loadConfig(key: String) = configuration.getOptional[String](key).getOrElse(throw new Exception(s"Missing configuration key: $key")) + private def loadConfig(key: String) = configuration.getString(key).getOrElse(throw new Exception(s"Missing configuration key: $key")) - override lazy val authURL = servicesConfig.baseUrl("auth") - override lazy val ggAuthenticationURL = servicesConfig.baseUrl("gg-authentication") - override lazy val ggURL = servicesConfig.baseUrl("government-gateway") - override lazy val ggAdminURL = servicesConfig.baseUrl("gg-admin") + override lazy val authURL = baseUrl("auth") + override lazy val ggAuthenticationURL = baseUrl("gg-authentication") + override lazy val ggURL = baseUrl("government-gateway") + override lazy val ggAdminURL = baseUrl("gg-admin") private def desBase = if (isEnabled(featureswitch.StubDESFeature)) "microservice.services.stub-des" @@ -54,8 +55,9 @@ class MicroserviceAppConfig @Inject()(servicesConfig: ServicesConfig, configurat override lazy val desToken = loadConfig(s"$desBase.authorization-token") override val paperlessPreferencesExpirySeconds: Int = { val key = s"paperless-preference.expiry-seconds" - configuration.getOptional[Int](key).getOrElse(throw new Exception(s"Missing configuration key: $key")) - + configuration.getInt(s"paperless-preference.expiry-seconds") + .getOrElse(throw new Exception(s"Missing configuration key: $key")) } + override protected def runModeConfiguration: Configuration = configuration } diff --git a/app/controllers/digitalcontact/PaperlessPreferenceController.scala b/app/controllers/digitalcontact/PaperlessPreferenceController.scala index 47e349d7..d1fa080e 100644 --- a/app/controllers/digitalcontact/PaperlessPreferenceController.scala +++ b/app/controllers/digitalcontact/PaperlessPreferenceController.scala @@ -16,22 +16,22 @@ package controllers.digitalcontact -import common.Constants._ import javax.inject.{Inject, Singleton} + +import common.Constants._ import models.digitalcontact.PaperlessPreferenceKey import play.api.libs.json.{JsError, JsSuccess, JsValue, Json} -import play.api.mvc.{Action, AnyContent, ControllerComponents} +import play.api.mvc.{Action, AnyContent} import services.AuthService import services.digitalcontact.PaperlessPreferenceService -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import uk.gov.hmrc.play.bootstrap.controller.BaseController import scala.concurrent.{ExecutionContext, Future} @Singleton class PaperlessPreferenceController @Inject()(authService: AuthService, - paperlessPreferenceService: PaperlessPreferenceService, - cc: ControllerComponents)(implicit ec: ExecutionContext) - extends BackendController(cc) { + paperlessPreferenceService: PaperlessPreferenceService)(implicit ec: ExecutionContext) + extends BaseController { import authService._ diff --git a/app/controllers/matching/LockoutStatusController.scala b/app/controllers/matching/LockoutStatusController.scala index 5267c391..51829cc9 100644 --- a/app/controllers/matching/LockoutStatusController.scala +++ b/app/controllers/matching/LockoutStatusController.scala @@ -17,20 +17,20 @@ package controllers.matching import javax.inject.{Inject, Singleton} + import models.lockout.LockoutRequest import models.matching.LockoutResponse import play.api.libs.json.Json -import play.api.mvc.{Action, AnyContent, ControllerComponents} +import play.api.mvc.{Action, AnyContent} import services.{AuthService, LockoutStatusService} -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import uk.gov.hmrc.play.bootstrap.controller.BaseController import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future @Singleton class LockoutStatusController @Inject()(authService: AuthService, - lockoutStatusService: LockoutStatusService, - cc: ControllerComponents) extends BackendController(cc) { + lockoutStatusService: LockoutStatusService) extends BaseController { import authService._ diff --git a/app/controllers/subscription/SubscriptionController.scala b/app/controllers/subscription/SubscriptionController.scala index 06279f74..4c877f6f 100644 --- a/app/controllers/subscription/SubscriptionController.scala +++ b/app/controllers/subscription/SubscriptionController.scala @@ -16,25 +16,25 @@ package controllers.subscription +import javax.inject.Inject + import audit.{Logging, LoggingConfig} import controllers.ITSASessionKeys -import javax.inject.Inject import models.frontend.{FEFailureResponse, FERequest} import play.api.libs.json.{JsError, JsSuccess} -import play.api.mvc._ +import play.api.mvc.{Action, AnyContent, Request, Result} import services.{AuthService, RosmAndEnrolManagerService} -import uk.gov.hmrc.http.HeaderCarrier -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import uk.gov.hmrc.play.bootstrap.controller.BaseController import utils.JsonUtils._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future +import uk.gov.hmrc.http.HeaderCarrier class SubscriptionController @Inject()(logging: Logging, subManService: RosmAndEnrolManagerService, - authService: AuthService, - cc: ControllerComponents - ) extends BackendController(cc) { + authService: AuthService + ) extends BaseController { import authService._ def subscribe(nino: String): Action[AnyContent] = Action.async { implicit request => diff --git a/app/controllers/subscription/SubscriptionStatusController.scala b/app/controllers/subscription/SubscriptionStatusController.scala index c81d5561..3cd20181 100644 --- a/app/controllers/subscription/SubscriptionStatusController.scala +++ b/app/controllers/subscription/SubscriptionStatusController.scala @@ -16,13 +16,13 @@ package controllers.subscription -import audit.{Logging, LoggingConfig} import javax.inject.Inject + +import audit.{Logging, LoggingConfig} import models.frontend.FEFailureResponse -import play.api.libs.json.Json -import play.api.mvc.{Action, AnyContent, ControllerComponents} +import play.api.mvc.{Action, AnyContent} import services.{AuthService, SubscriptionStatusService} -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import uk.gov.hmrc.play.bootstrap.controller.BaseController import utils.Implicits._ import utils.JsonUtils.toJsValue @@ -30,9 +30,7 @@ import scala.concurrent.ExecutionContext.Implicits.global class SubscriptionStatusController @Inject()(logging: Logging, authService: AuthService, - subscriptionStatusService: SubscriptionStatusService, - cc: ControllerComponents) extends BackendController(cc) { - + subscriptionStatusService: SubscriptionStatusService) extends BaseController { import authService._ def checkSubscriptionStatus(nino: String): Action[AnyContent] = Action.async { implicit request => @@ -41,10 +39,7 @@ class SubscriptionStatusController @Inject()(logging: Logging, subscriptionStatusService.checkMtditsaSubscription(nino).map { case Right(success) => logging.debug(s"successful, responding with\n$success") - success match { - case None => Ok(Json.obj()) - case _ => Ok(toJsValue(success)) - } + Ok(toJsValue(success)) case Left(failure) => logging.warn(s"failed, responding with\nstatus=${failure.status}\nreason=${failure.reason}") Status(failure.status)(toJsValue(FEFailureResponse(failure.reason))) diff --git a/app/testonly/controllers/featureswitch/FeatureSwitchController.scala b/app/testonly/controllers/featureswitch/FeatureSwitchController.scala index e739bb50..ce528f2f 100644 --- a/app/testonly/controllers/featureswitch/FeatureSwitchController.scala +++ b/app/testonly/controllers/featureswitch/FeatureSwitchController.scala @@ -16,17 +16,19 @@ package testonly.controllers.featureswitch +import javax.inject.Inject + import config.featureswitch.FeatureSwitch._ import config.featureswitch.{FeatureSwitch, FeatureSwitching} -import javax.inject.Inject +import play.api.i18n.MessagesApi import play.api.libs.json.Json -import play.api.mvc.{ControllerComponents, Result} -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import play.api.mvc.{Action, Result} +import uk.gov.hmrc.play.bootstrap.controller.BaseController import scala.concurrent.Future -class FeatureSwitchController @Inject()(cc: ControllerComponents) - extends BackendController(cc) with FeatureSwitching { +class FeatureSwitchController @Inject()(val messagesApi: MessagesApi) + extends BaseController with FeatureSwitching { private def returnCurrentSettings = Ok(Json.toJson(switches.map(fs => FeatureSwitchSetting(fs, isEnabled(fs))))) diff --git a/app/testonly/controllers/matching/ResetAgentLockoutController.scala b/app/testonly/controllers/matching/ResetAgentLockoutController.scala index 0227a55c..b3bda25a 100644 --- a/app/testonly/controllers/matching/ResetAgentLockoutController.scala +++ b/app/testonly/controllers/matching/ResetAgentLockoutController.scala @@ -17,15 +17,14 @@ package testonly.controllers.matching import javax.inject.{Inject, Singleton} -import play.api.mvc.{Action, AnyContent, ControllerComponents} -import repositories.LockoutMongoRepository -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import play.api.mvc.{Action, AnyContent} +import repositories.LockoutMongoRepository +import uk.gov.hmrc.play.bootstrap.controller.BaseController import scala.concurrent.ExecutionContext.Implicits.global @Singleton -class ResetAgentLockoutController @Inject()(mongoRepository: LockoutMongoRepository, - cc: ControllerComponents) extends BackendController(cc) { +class ResetAgentLockoutController @Inject()(mongoRepository: LockoutMongoRepository) extends BaseController { def resetAgentLockout: Action[AnyContent] = Action.async { implicit request => mongoRepository.dropDb map (_ => Ok) diff --git a/build.sbt b/build.sbt index 4436bfaf..8f98a0f7 100644 --- a/build.sbt +++ b/build.sbt @@ -49,9 +49,9 @@ lazy val microservice = Project(appName, file(".")) resolvers += Resolver.bintrayRepo("hmrc", "releases"), resolvers += Resolver.jcenterRepo, libraryDependencies ++= appDependencies, - dependencyOverrides ++= AppDependencies.overrides, retrieveManaged := true, - evictionWarningOptions in update := EvictionWarningOptions.default.withWarnScalaVersionEviction(false) + evictionWarningOptions in update := EvictionWarningOptions.default.withWarnScalaVersionEviction(false), + routesGenerator := StaticRoutesGenerator ) .configs(IntegrationTest) .settings(inConfig(IntegrationTest)(Defaults.itSettings): _*) diff --git a/it/controllers/digitalcontact/PaperlessPreferenceControllerISpec.scala b/it/controllers/digitalcontact/PaperlessPreferenceControllerISpec.scala index 3fb7ba27..cdd0d94e 100644 --- a/it/controllers/digitalcontact/PaperlessPreferenceControllerISpec.scala +++ b/it/controllers/digitalcontact/PaperlessPreferenceControllerISpec.scala @@ -19,6 +19,7 @@ package controllers.digitalcontact import helpers.ComponentSpecBase import helpers.servicemocks.AuthStub import models.digitalcontact.PaperlessPreferenceKey +import org.scalatest.BeforeAndAfterEach import play.api.http.Status import repositories.digitalcontact.PaperlessPreferenceMongoRepository import helpers.IntegrationTestConstants._ @@ -26,7 +27,7 @@ import play.api.libs.json.Json import scala.concurrent.ExecutionContext.Implicits.global -class PaperlessPreferenceControllerISpec extends ComponentSpecBase { +class PaperlessPreferenceControllerISpec extends ComponentSpecBase with BeforeAndAfterEach { val paperlessPreferenceRepository = app.injector.instanceOf[PaperlessPreferenceMongoRepository] override def beforeEach(): Unit = { diff --git a/it/controllers/matching/LockoutStatusControllerISpec.scala b/it/controllers/matching/LockoutStatusControllerISpec.scala index 83750c48..af3a425a 100644 --- a/it/controllers/matching/LockoutStatusControllerISpec.scala +++ b/it/controllers/matching/LockoutStatusControllerISpec.scala @@ -26,7 +26,7 @@ import play.modules.reactivemongo.ReactiveMongoComponent import repositories.LockoutMongoRepository import scala.concurrent.ExecutionContext.Implicits.global -class LockoutStatusControllerISpec extends ComponentSpecBase { +class LockoutStatusControllerISpec extends ComponentSpecBase with BeforeAndAfterEach { implicit lazy val mongo = app.injector.instanceOf[ReactiveMongoComponent] object TestLockoutMongoRepository extends LockoutMongoRepository diff --git a/it/helpers/ComponentSpecBase.scala b/it/helpers/ComponentSpecBase.scala index f0e4e9d7..754c0784 100644 --- a/it/helpers/ComponentSpecBase.scala +++ b/it/helpers/ComponentSpecBase.scala @@ -95,7 +95,7 @@ trait ComponentSpecBase extends UnitSpec def post[T](uri: String, body: T)(implicit writes: Writes[T]): WSResponse = { await( buildClient(uri) - .withHttpHeaders( + .withHeaders( "Content-Type" -> "application/json", ITSASessionKeys.RequestURI -> IntegrationTestConstants.requestUri ) diff --git a/it/helpers/WiremockHelper.scala b/it/helpers/WiremockHelper.scala index 0f83e80e..34c53df1 100644 --- a/it/helpers/WiremockHelper.scala +++ b/it/helpers/WiremockHelper.scala @@ -35,7 +35,7 @@ object WiremockHelper extends Eventually with IntegrationPatience { case Some(body) => uriMapping.withRequestBody(equalTo(body)) case None => uriMapping } - verify(postRequest) + verify(postRequest) } def verifyGet(uri: String): Unit = { diff --git a/it/helpers/servicemocks/WireMockMethods.scala b/it/helpers/servicemocks/WireMockMethods.scala index 58373034..a6b85334 100644 --- a/it/helpers/servicemocks/WireMockMethods.scala +++ b/it/helpers/servicemocks/WireMockMethods.scala @@ -97,12 +97,12 @@ trait WireMockMethods { val wireMockMapping: UrlPattern => MappingBuilder } case object GET extends HTTPMethod { - override val wireMockMapping: UrlPattern => MappingBuilder = get + override val wireMockMapping = get _ } case object POST extends HTTPMethod { - override val wireMockMapping: UrlPattern => MappingBuilder = post + override val wireMockMapping = post _ } case object PUT extends HTTPMethod{ - override val wireMockMapping: UrlPattern => MappingBuilder = put + override val wireMockMapping = put _ } } diff --git a/project/MicroServiceBuild.scala b/project/MicroServiceBuild.scala index 45aeb1d7..abfa99aa 100644 --- a/project/MicroServiceBuild.scala +++ b/project/MicroServiceBuild.scala @@ -29,22 +29,26 @@ private object AppDependencies { private val domainVersion = "5.1.0" private val hmrcTestVersion = "3.0.0" - private val scalaTestVersion = "3.0.5" - private val scalaTestPlusVersion = "3.1.2" + private val scalaTestVersion = "3.0.1" + private val scalaTestPlusVersion = "2.0.0" private val pegdownVersion = "1.6.0" private val mockitoVersion = "2.7.17" + private val scalaJVersion = "2.3.0" private val cucumberVersion = "1.2.5" - private val reactiveMongoVersion = "7.3.0-play-26" - private val wiremockVersion = "2.19.0" - private val bootstrapVersion = "0.30.0" + + private val reactiveMongoVersion = "6.2.0" + + private val wiremockVersion = "2.5.1" + + private val bootstrapVersion = "1.7.0" val compile = Seq( ws, - "uk.gov.hmrc" %% "bootstrap-play-26" % bootstrapVersion, + "uk.gov.hmrc" %% "bootstrap-play-25" % bootstrapVersion, "uk.gov.hmrc" %% "domain" % domainVersion, - "uk.gov.hmrc" %% "simple-reactivemongo" % reactiveMongoVersion + "uk.gov.hmrc" %% "play-reactivemongo" % reactiveMongoVersion ) trait TestDependencies { @@ -90,25 +94,6 @@ private object AppDependencies { }.test } - // Fixes a transitive dependency clash between wiremock and scalatestplus-play - val overrides: Set[ModuleID] = { - val jettyFromWiremockVersion = "9.2.24.v20180105" - Set( - "org.eclipse.jetty" % "jetty-client" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-continuation" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-http" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-io" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-security" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-server" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-servlet" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-servlets" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-util" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-webapp" % jettyFromWiremockVersion, - "org.eclipse.jetty" % "jetty-xml" % jettyFromWiremockVersion, - "org.eclipse.jetty.websocket" % "websocket-api" % jettyFromWiremockVersion, - "org.eclipse.jetty.websocket" % "websocket-client" % jettyFromWiremockVersion, - "org.eclipse.jetty.websocket" % "websocket-common" % jettyFromWiremockVersion - ) - } def apply() = compile ++ Test() ++ IntegrationTest() } + diff --git a/project/plugins.sbt b/project/plugins.sbt index 610217f4..d3d4d626 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -8,9 +8,9 @@ addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.13.0") addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "1.15.0") -addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.2.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.0.0") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.15") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.12") resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(Resolver.ivyStylePatterns) @@ -18,7 +18,7 @@ addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0") addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0") -addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.14.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.13.0") diff --git a/test/connectors/mocks/TestBusinessDetailsConnector.scala b/test/connectors/mocks/TestBusinessDetailsConnector.scala index cf0ffc20..03b5677f 100644 --- a/test/connectors/mocks/TestBusinessDetailsConnector.scala +++ b/test/connectors/mocks/TestBusinessDetailsConnector.scala @@ -23,10 +23,12 @@ import models.ErrorModel import models.registration.GetBusinessDetailsSuccessResponseModel import org.mockito.ArgumentMatchers import org.mockito.Mockito._ +import org.mockito._ import org.scalatest.mockito.MockitoSugar import org.scalatestplus.play.guice.GuiceOneAppPerSuite import play.api.http.Status._ import play.api.libs.json.JsValue +import uk.gov.hmrc.http.{HttpGet, HttpPost} import uk.gov.hmrc.play.bootstrap.http.HttpClient import utils.Implicits._ import utils.TestConstants._ diff --git a/test/connectors/mocks/TestRegistrationConnector.scala b/test/connectors/mocks/TestRegistrationConnector.scala index c40f7b21..6186c5c5 100644 --- a/test/connectors/mocks/TestRegistrationConnector.scala +++ b/test/connectors/mocks/TestRegistrationConnector.scala @@ -26,7 +26,7 @@ import org.scalatest.mockito.MockitoSugar import org.scalatestplus.play.guice.GuiceOneAppPerSuite import play.api.http.Status._ import play.api.libs.json.JsValue -import uk.gov.hmrc.http.HttpPost +import uk.gov.hmrc.http.{HttpGet, HttpPost} import uk.gov.hmrc.play.bootstrap.http.HttpClient import utils.Implicits._ import utils.TestConstants.{GetRegistrationResponse, NewRegistrationResponse, _} diff --git a/test/connectors/mocks/TestSubscriptionConnector.scala b/test/connectors/mocks/TestSubscriptionConnector.scala index 06795403..add9f2f0 100644 --- a/test/connectors/mocks/TestSubscriptionConnector.scala +++ b/test/connectors/mocks/TestSubscriptionConnector.scala @@ -26,7 +26,7 @@ import org.scalatest.mockito.MockitoSugar import org.scalatestplus.play.guice.GuiceOneAppPerSuite import play.api.http.Status._ import play.api.libs.json.JsValue -import uk.gov.hmrc.http.HeaderCarrier +import uk.gov.hmrc.http.{HeaderCarrier, HttpPost} import uk.gov.hmrc.play.bootstrap.http.HttpClient import utils.JsonUtils._ import utils.TestConstants.{BusinessSubscriptionResponse, PropertySubscriptionResponse, _} diff --git a/test/controllers/digitalcontact/PaperlessPreferenceControllerSpec.scala b/test/controllers/digitalcontact/PaperlessPreferenceControllerSpec.scala index cd99acb6..9883ab57 100644 --- a/test/controllers/digitalcontact/PaperlessPreferenceControllerSpec.scala +++ b/test/controllers/digitalcontact/PaperlessPreferenceControllerSpec.scala @@ -21,11 +21,11 @@ import models.digitalcontact.PaperlessPreferenceKey import play.api.libs.json.{JsValue, Json} import play.api.mvc.Result import play.api.test.FakeRequest -import play.api.test.Helpers._ import services.mocks.{MockAuthService, MockPaperlessPreferenceService} import uk.gov.hmrc.play.test.UnitSpec import utils.MaterializerSupport import utils.TestConstants._ +import play.api.test.Helpers._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future @@ -34,8 +34,7 @@ class PaperlessPreferenceControllerSpec extends UnitSpec with MaterializerSuppor object TestPaperlessPreferenceController extends PaperlessPreferenceController( mockAuthService, - mockPaperlessPreferenceService, - stubControllerComponents() + mockPaperlessPreferenceService ) s"storeNino($testPreferencesToken)" should { diff --git a/test/controllers/matching/LockoutStatusControllerSpec.scala b/test/controllers/matching/LockoutStatusControllerSpec.scala index cfcbc100..50cd409b 100644 --- a/test/controllers/matching/LockoutStatusControllerSpec.scala +++ b/test/controllers/matching/LockoutStatusControllerSpec.scala @@ -31,7 +31,7 @@ import scala.concurrent.Future class LockoutStatusControllerSpec extends UnitSpec with MockLockoutStatusService with MaterializerSupport with MockAuthService { - object TestController extends LockoutStatusController(mockAuthService, mockLockoutStatusService, stubControllerComponents()) + object TestController extends LockoutStatusController(mockAuthService, mockLockoutStatusService) "LockoutStatusController.checkLockoutStatus" should { def call: Future[Result] = TestController.checkLockoutStatus(testArn)(FakeRequest()) diff --git a/test/controllers/subscription/SubscriptionControllerSpec.scala b/test/controllers/subscription/SubscriptionControllerSpec.scala index 4bbd106b..f786923a 100644 --- a/test/controllers/subscription/SubscriptionControllerSpec.scala +++ b/test/controllers/subscription/SubscriptionControllerSpec.scala @@ -22,7 +22,6 @@ import models.frontend.FESuccessResponse import play.api.http.Status._ import play.api.mvc.{AnyContentAsJson, Request, Result} import play.api.test.FakeRequest -import play.api.test.Helpers.stubControllerComponents import services.mocks.{MockAuthService, MockSubscriptionManagerService} import uk.gov.hmrc.play.test.UnitSpec import utils.JsonUtils._ @@ -35,7 +34,7 @@ class SubscriptionControllerSpec extends UnitSpec with MockSubscriptionManagerSe val logging = mock[Logging] - object TestController extends SubscriptionController(logging, mockSubscriptionManagerService, mockAuthService, stubControllerComponents()) + object TestController extends SubscriptionController(logging, mockSubscriptionManagerService, mockAuthService) def call(request: Request[AnyContentAsJson]): Future[Result] = TestController.subscribe(testNino)(request) diff --git a/test/controllers/subscription/SubscriptionStatusControllerSpec.scala b/test/controllers/subscription/SubscriptionStatusControllerSpec.scala index d96ba18b..b86f50bb 100644 --- a/test/controllers/subscription/SubscriptionStatusControllerSpec.scala +++ b/test/controllers/subscription/SubscriptionStatusControllerSpec.scala @@ -21,7 +21,6 @@ import models.frontend.FESuccessResponse import play.api.http.Status._ import play.api.mvc.Result import play.api.test.FakeRequest -import play.api.test.Helpers.stubControllerComponents import services.mocks.{MockAuthService, MockSubscriptionStatusService} import uk.gov.hmrc.play.test.UnitSpec import utils.MaterializerSupport @@ -33,7 +32,7 @@ class SubscriptionStatusControllerSpec extends UnitSpec with MockSubscriptionSta val logging = mock[Logging] - object TestController extends SubscriptionStatusController(logging, mockAuthService, mockSubscriptionStatusService, stubControllerComponents()) + object TestController extends SubscriptionStatusController(logging, mockAuthService, mockSubscriptionStatusService) def call: Future[Result] = TestController.checkSubscriptionStatus(testNino)(FakeRequest()) @@ -42,7 +41,7 @@ class SubscriptionStatusControllerSpec extends UnitSpec with MockSubscriptionSta mockCheckMtditsaNotFound(testNino) mockAuthSuccess() - val result = await(call) + val result = call status(result) shouldBe OK jsonBodyOf(result).as[FESuccessResponse].mtditId shouldBe None } @@ -51,7 +50,7 @@ class SubscriptionStatusControllerSpec extends UnitSpec with MockSubscriptionSta mockCheckMtditsaFound(testNino) mockAuthSuccess() - val result = await(call) + val result = call status(result) shouldBe OK jsonBodyOf(result).as[FESuccessResponse].mtditId shouldBe Some(testMtditId) } diff --git a/test/services/mocks/TestSubscriptionService.scala b/test/services/mocks/TestSubscriptionService.scala index 22afa243..abdd517c 100644 --- a/test/services/mocks/TestSubscriptionService.scala +++ b/test/services/mocks/TestSubscriptionService.scala @@ -27,10 +27,10 @@ import org.mockito.Mockito._ import org.scalatest.mockito.MockitoSugar import org.scalatestplus.play.guice.GuiceOneAppPerSuite import services.SubscriptionService -import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.play.test.UnitSpec import scala.concurrent.Future +import uk.gov.hmrc.http.HeaderCarrier trait MockSubscriptionService extends MockitoSugar { val mockSubscriptionService = mock[SubscriptionService]