diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/service/Auditor.scala b/app/uk/gov/hmrc/merchandiseinbaggage/service/Auditor.scala index 52fb34826..0c1c246cb 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggage/service/Auditor.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggage/service/Auditor.scala @@ -17,7 +17,6 @@ package uk.gov.hmrc.merchandiseinbaggage.service import play.api.Logging -import play.api.i18n.MessagesApi import play.api.libs.json.Json.toJson import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration @@ -30,7 +29,6 @@ import scala.util.control.NonFatal trait Auditor extends Logging { val auditConnector: AuditConnector - val messagesApi: MessagesApi def auditDeclaration(declaration: Declaration)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Unit] = { val eventType = "DeclarationPaymentAttempted" diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/service/PaymentService.scala b/app/uk/gov/hmrc/merchandiseinbaggage/service/PaymentService.scala index 9b15145be..64fd10e88 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggage/service/PaymentService.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggage/service/PaymentService.scala @@ -17,26 +17,23 @@ package uk.gov.hmrc.merchandiseinbaggage.service import com.google.inject.Singleton -import play.api.i18n.MessagesApi import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig import uk.gov.hmrc.merchandiseinbaggage.connectors.PaymentConnector import uk.gov.hmrc.merchandiseinbaggage.controllers.routes import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration - -import javax.inject.Inject import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation.CalculationResults import uk.gov.hmrc.merchandiseinbaggage.model.api.payapi.PayApiRequest - -import scala.concurrent.{ExecutionContext, Future} import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._ import uk.gov.hmrc.play.audit.http.connector.AuditConnector +import javax.inject.Inject +import scala.concurrent.{ExecutionContext, Future} + @Singleton class PaymentService @Inject() ( connector: PaymentConnector, - val auditConnector: AuditConnector, - val messagesApi: MessagesApi + val auditConnector: AuditConnector )(implicit ec: ExecutionContext, appConfig: AppConfig) extends Auditor { diff --git a/app/uk/gov/hmrc/merchandiseinbaggage/service/TpsPaymentsService.scala b/app/uk/gov/hmrc/merchandiseinbaggage/service/TpsPaymentsService.scala index 9e225efc5..ea706d982 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggage/service/TpsPaymentsService.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggage/service/TpsPaymentsService.scala @@ -16,25 +16,23 @@ package uk.gov.hmrc.merchandiseinbaggage.service -import javax.inject.{Inject, Singleton} import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig import uk.gov.hmrc.merchandiseinbaggage.connectors.TpsPaymentsBackendConnector import uk.gov.hmrc.merchandiseinbaggage.model.api.Declaration import uk.gov.hmrc.merchandiseinbaggage.model.api.calculation.CalculationResults +import uk.gov.hmrc.merchandiseinbaggage.model.api.payapi.PayApiResponse import uk.gov.hmrc.merchandiseinbaggage.model.api.tpspayments.TpsPaymentsRequest import uk.gov.hmrc.merchandiseinbaggage.utils.DataModelEnriched._ +import uk.gov.hmrc.play.audit.http.connector.AuditConnector +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} -import play.api.i18n.MessagesApi -import uk.gov.hmrc.merchandiseinbaggage.model.api.payapi.PayApiResponse -import uk.gov.hmrc.play.audit.http.connector.AuditConnector @Singleton class TpsPaymentsService @Inject() ( connector: TpsPaymentsBackendConnector, - val auditConnector: AuditConnector, - val messagesApi: MessagesApi + val auditConnector: AuditConnector )(implicit ec: ExecutionContext, appConfig: AppConfig) extends Auditor { diff --git a/conf/messages.en b/conf/messages similarity index 100% rename from conf/messages.en rename to conf/messages diff --git a/conf/messages.cy b/conf/messages.cy index e598ddb45..ccf01e691 100644 --- a/conf/messages.cy +++ b/conf/messages.cy @@ -528,12 +528,11 @@ declarationConfirmation.ul.1.1 = (dim byd i’w ddatgan) wrth y tollau declarationConfirmation.ul.2 = mynd â’r datganiad a anfonwyd at y cyfeiriad a roddwyd declarationConfirmation.ul.3 = mynd â’r derbynebau neu’r anfonebau ar gyfer yr holl nwyddau a ddatganwyd declarationConfirmation.ul.4 = ewch â thystiolaeth sy’n dangos ble y cafodd y nwyddau o’r UE eu cynhyrchu -declarationConfirmation.date = Dyddiad y datganiad declarationConfirmation.email = Rydym wedi anfon e-bost cadarnhau i’r cyfeiriad a roddwyd. declarationConfirmation.makeAnotherDeclaration = Gwneud datganiad newydd declarationConfirmation.changeDeclaration.label = Ychwanegu nwyddau i ddatganiad sy’n bodoli eisoes declarationConfirmation.feedbackSurvey = Beth oedd eich barn am y gwasanaeth hwn? -declarationConfirmation.feedbackSurvey.info = (mae'n cymryd 30 eiliad) +declarationConfirmation.feedbackSurvey.info = (mae‘n cymryd 30 eiliad) declarationConfirmation.printOrSave.label = Argraffu neu gadw copi o’r dudalen hon declarationConfirmation.declaration.label = Datganiad declarationConfirmation.declaration.text = Nwyddau masnachol sy’n cael eu cario mewn bagiau neu gerbydau bach @@ -1106,4 +1105,4 @@ title.august = Awst title.september = Medi title.october = Hydref title.november = Tachwedd -title.december = Rhagfyr \ No newline at end of file +title.december = Rhagfyr diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index 0fce806b0..a8d839529 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -6,11 +6,11 @@ object AppDependencies { private val compile: Seq[ModuleID] = Seq( "uk.gov.hmrc" %% "bootstrap-frontend-play-30" % bootstrapVersion, - "uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "11.7.0", + "uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "11.8.0", "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % "2.3.0", "com.beachape" %% "enumeratum-play" % "1.8.2", "org.webjars.npm" % "accessible-autocomplete" % "3.0.0", - "com.softwaremill.quicklens" %% "quicklens" % "1.9.10", + "com.softwaremill.quicklens" %% "quicklens" % "1.9.11", "org.typelevel" %% "cats-core" % "2.12.0", "io.github.samueleresca" %% "pekko-quartz-scheduler" % "1.2.2-pekko-1.0.x" ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 1c954cb51..f65264061 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,10 +3,10 @@ resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefact Resolver.ivyStylePatterns ) -addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.22.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.24.0") addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0") addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.5") addSbtPlugin("io.github.irundaia" % "sbt-sassify" % "1.5.2") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.2") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") diff --git a/test/resources/logback-test.xml b/test/resources/logback-test.xml index 6a3c8b9e1..9233c08f8 100644 --- a/test/resources/logback-test.xml +++ b/test/resources/logback-test.xml @@ -1,6 +1,15 @@ - + + + + %date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n + + + + + + diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/BaseSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/BaseSpec.scala index 47640b2ed..b6cf72f72 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/BaseSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/BaseSpec.scala @@ -23,7 +23,7 @@ import org.scalatest.matchers.must.Matchers import org.scalatest.time.{Milliseconds, Seconds, Span} import org.scalatest.wordspec.AnyWordSpec import org.scalatestplus.play.guice.GuiceOneServerPerSuite -import play.api.i18n.{Messages, MessagesApi} +import play.api.i18n.{Lang, Messages, MessagesApi} import play.api.inject.guice.GuiceApplicationBuilder import play.api.inject.{ApplicationLifecycle, Injector} import play.api.mvc.{AnyContentAsEmpty, DefaultActionBuilder} @@ -56,10 +56,12 @@ trait BaseSpecWithApplication extends BaseSpec with GuiceOneServerPerSuite with lazy val defaultBuilder: DefaultActionBuilder = injector.instanceOf[DefaultActionBuilder] implicit lazy val appConfig: AppConfig = injector.instanceOf[AppConfig] - def messagesApi: MessagesApi = injector.instanceOf[MessagesApi] lazy val fakeRequest: FakeRequest[AnyContentAsEmpty.type] = FakeRequest("", "").withCSRFToken.asInstanceOf[FakeRequest[AnyContentAsEmpty.type]] - implicit val messages: Messages = messagesApi.preferred(fakeRequest) + lazy val messagesApi: MessagesApi = injector.instanceOf[MessagesApi] + private val lang: Lang = Lang("en") + private val cyLang: Lang = Lang("cy") + implicit val messages: Messages = injector.instanceOf[MessagesApi].preferred(Seq(lang, cyLang)) implicit val headerCarrier: HeaderCarrier = HeaderCarrier() lazy val injector: Injector = app.injector diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala index 6d75b4e27..216337511 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/AgentDetailsControllerSpec.scala @@ -55,8 +55,8 @@ class AgentDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("agentDetails.title")) - result must include(messageApi("agentDetails.heading")) + result must include(messages("agentDetails.title")) + result must include(messages("agentDetails.heading")) } } @@ -93,8 +93,8 @@ class AgentDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi(s"agentDetails.title")) - result must include(messageApi(s"agentDetails.heading")) + result must include(messages("error.summary.title")) + result must include(messages(s"agentDetails.title")) + result must include(messages(s"agentDetails.heading")) } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala index a898ebb56..19d6798d3 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotAccessPageControllerSpec.scala @@ -39,9 +39,9 @@ class CannotAccessPageControllerSpec extends DeclarationJourneyControllerSpec wi val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"invalidRequest.li1")) - result must include(messageApi(s"invalidRequest.li2")) - result must include(messageApi(s"invalidRequest.$importOrExport.restart")) + result must include(messages(s"invalidRequest.li1")) + result must include(messages(s"invalidRequest.li2")) + result must include(messages(s"invalidRequest.$importOrExport.restart")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala index 9fca328d7..972335764 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceControllerSpec.scala @@ -42,9 +42,9 @@ class CannotUseServiceControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"cannotUseService.$importOrExport.title")) - result must include(messageApi(s"cannotUseService.$importOrExport.heading")) - result must include(messageApi(s"cannotUseService.$importOrExport.p1")) + result must include(messages(s"cannotUseService.$importOrExport.title")) + result must include(messages(s"cannotUseService.$importOrExport.heading")) + result must include(messages(s"cannotUseService.$importOrExport.p1")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala index 49d61efd0..df1af49f0 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CannotUseServiceIrelandControllerSpec.scala @@ -42,10 +42,10 @@ class CannotUseServiceIrelandControllerSpec extends DeclarationJourneyController val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"cannotUseServiceIreland.title")) - result must include(messageApi(s"cannotUseServiceIreland.heading")) - result must include(messageApi(s"cannotUseServiceIreland.p1")) - result must include(messageApi(s"cannotUseServiceIreland.p1.$importOrExport.a.text")) + result must include(messages(s"cannotUseServiceIreland.title")) + result must include(messages(s"cannotUseServiceIreland.heading")) + result must include(messages(s"cannotUseServiceIreland.p1")) + result must include(messages(s"cannotUseServiceIreland.p1.$importOrExport.a.text")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala index e1412f0be..390c1ebfe 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersAmendHandlerSpec.scala @@ -97,7 +97,7 @@ class CheckYourAnswersAmendHandlerSpec extends DeclarationJourneyControllerSpec val eventualResult = amendHandler().onPageLoad(journey, amendment, YesNo.No) status(eventualResult) mustBe OK - contentAsString(eventualResult) must include(messageApi("checkYourAnswers.amend.title")) + contentAsString(eventualResult) must include(messages("checkYourAnswers.amend.title")) } s"will calculate tax and send payment request to TPS for $importOrExport" in { diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala index 8ea9af8f6..bdefdaf36 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersControllerSpec.scala @@ -66,7 +66,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec { new CheckYourAnswersNewHandler( mockMibService, mockTpsService, - new PaymentService(testPaymentConnector, auditConnector, messagesApi), + new PaymentService(testPaymentConnector, auditConnector), mibConnector, importView, exportView @@ -77,7 +77,7 @@ class CheckYourAnswersControllerSpec extends DeclarationJourneyControllerSpec { actionBuilder, mockMibService, mockTpsService, - new PaymentService(testPaymentConnector, auditConnector, messagesApi), + new PaymentService(testPaymentConnector, auditConnector), amendImportView, amendExportView ) diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala index 79f9d7413..0d9c8d19e 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CheckYourAnswersNewHandlerSpec.scala @@ -72,7 +72,7 @@ class CheckYourAnswersNewHandlerSpec extends DeclarationJourneyControllerSpec { new CheckYourAnswersNewHandler( stubbedCalculation(paymentCalcs), mockTpsPaymentsService, - new PaymentService(testPaymentConnector, auditConnector, messagesApi), + new PaymentService(testPaymentConnector, auditConnector), testMibConnector, importView, exportView @@ -95,7 +95,7 @@ class CheckYourAnswersNewHandlerSpec extends DeclarationJourneyControllerSpec { val result = newHandler().onPageLoad(declaration, YesNo.Yes) status(result) mustBe OK - contentAsString(result) must include(messageApi("checkYourAnswers.title")) + contentAsString(result) must include(messages("checkYourAnswers.title")) } s"return 303 for goods over threshold for $importOrExport" in { diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala index 57cf62f16..19b1f30a0 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/CustomsAgentControllerSpec.scala @@ -55,9 +55,9 @@ class CustomsAgentControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("customsAgent.title")) - result must include(messageApi("customsAgent.heading")) - result must include(messageApi("customsAgent.hint")) + result must include(messages("customsAgent.title")) + result must include(messages("customsAgent.heading")) + result must include(messages("customsAgent.hint")) } } @@ -93,9 +93,9 @@ class CustomsAgentControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi("customsAgent.title")) - result must include(messageApi("customsAgent.heading")) + result must include(messages("error.summary.title")) + result must include(messages("customsAgent.title")) + result must include(messages("customsAgent.heading")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala index 6b1396f2c..071682dcd 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/DeclarationConfirmationControllerSpec.scala @@ -57,7 +57,11 @@ class DeclarationConfirmationControllerSpec extends DeclarationJourneyController givenPersistedDeclarationIsFound(exportJourney.declarationIfRequiredAndComplete.get, id) val eventualResult = controller.onPageLoad()(request) + val result = contentAsString(eventualResult) + status(eventualResult) mustBe OK + result must include(messages("declarationConfirmation.title")) + result must include(messages("declarationConfirmation.banner.title")) import exportJourney._ val resetJourney = DeclarationJourney(sessionId, declarationType, isAssistedDigital = false) @@ -86,7 +90,11 @@ class DeclarationConfirmationControllerSpec extends DeclarationJourneyController givenPersistedDeclarationIsFound(declarationWithNoPaymentRequired, id) val eventualResult = controller.onPageLoad()(request) + val result = contentAsString(eventualResult) + status(eventualResult) mustBe OK + result must include(messages("declarationConfirmation.title")) + result must include(messages("declarationConfirmation.banner.title")) import importJourney._ val resetJourney = DeclarationJourney(sessionId, declarationType, isAssistedDigital = false) diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala index 4261cbf3b..24f202d62 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ExciseAndRestrictedGoodsControllerSpec.scala @@ -53,9 +53,9 @@ class ExciseAndRestrictedGoodsControllerSpec extends DeclarationJourneyControlle val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"exciseAndRestrictedGoods.$importOrExport.title")) - result must include(messageApi(s"exciseAndRestrictedGoods.$importOrExport.heading")) - result must include(messageApi("exciseAndRestrictedGoods.details")) + result must include(messages(s"exciseAndRestrictedGoods.$importOrExport.title")) + result must include(messages(s"exciseAndRestrictedGoods.$importOrExport.heading")) + result must include(messages("exciseAndRestrictedGoods.details")) } } @@ -92,9 +92,9 @@ class ExciseAndRestrictedGoodsControllerSpec extends DeclarationJourneyControlle val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi(s"exciseAndRestrictedGoods.$importOrExport.title")) - result must include(messageApi(s"exciseAndRestrictedGoods.$importOrExport.heading")) + result must include(messages("error.summary.title")) + result must include(messages(s"exciseAndRestrictedGoods.$importOrExport.title")) + result must include(messages(s"exciseAndRestrictedGoods.$importOrExport.heading")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala index f9be63485..98a689ca9 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsDestinationControllerSpec.scala @@ -55,12 +55,12 @@ class GoodsDestinationControllerSpec extends DeclarationJourneyControllerSpec wi val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"goodsDestination.$importOrExport.title")) - result must include(messageApi(s"goodsDestination.$importOrExport.heading")) - result must include(messageApi("goodsDestination.NorthernIreland")) - result must include(messageApi("goodsDestination.GreatBritain")) + result must include(messages(s"goodsDestination.$importOrExport.title")) + result must include(messages(s"goodsDestination.$importOrExport.heading")) + result must include(messages("goodsDestination.NorthernIreland")) + result must include(messages("goodsDestination.GreatBritain")) - result must include(messageApi(s"service.name.${importOrExport.entryName}.a.href")) + result must include(messages(s"service.name.${importOrExport.entryName}.a.href")) } } @@ -97,7 +97,7 @@ class GoodsDestinationControllerSpec extends DeclarationJourneyControllerSpec wi val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala index 871ef01ac..29dcc6160 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsInVehicleControllerSpec.scala @@ -98,7 +98,7 @@ class GoodsInVehicleControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) result must include(messages(s"goodsInVehicle.$importOrExport.title")) result must include(messages(s"goodsInVehicle.$importOrExport.heading")) } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala index 8341c5ac2..551852b86 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOriginControllerSpec.scala @@ -53,8 +53,8 @@ class GoodsOriginControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"goodsOrigin.title")) - result must include(messageApi(s"goodsOrigin.heading")) + result must include(messages(s"goodsOrigin.title")) + result must include(messages(s"goodsOrigin.heading")) } } @@ -91,8 +91,8 @@ class GoodsOriginControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi(s"goodsOrigin.title")) - result must include(messageApi(s"goodsOrigin.heading")) + result must include(messages("error.summary.title")) + result must include(messages(s"goodsOrigin.title")) + result must include(messages(s"goodsOrigin.heading")) } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala index 5928f7b7d..2fca65262 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsOverThresholdControllerSpec.scala @@ -54,11 +54,11 @@ class GoodsOverThresholdControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("goodsOverThreshold.GreatBritain.title", thresholdValueInUI)) - result must include(messageApi("goodsOverThreshold.GreatBritain.heading", thresholdValueInUI)) - result must include(messageApi(s"goodsOverThreshold.GreatBritain.$importOrExport.p1", thresholdValueInUI)) - result must include(messageApi("goodsOverThreshold.p2")) - result must include(messageApi(s"goodsOverThreshold.p2.$importOrExport.a.text")) + result must include(messages("goodsOverThreshold.GreatBritain.title", thresholdValueInUI)) + result must include(messages("goodsOverThreshold.GreatBritain.heading", thresholdValueInUI)) + result must include(messages(s"goodsOverThreshold.GreatBritain.$importOrExport.p1", thresholdValueInUI)) + result must include(messages("goodsOverThreshold.p2")) + result must include(messages(s"goodsOverThreshold.p2.$importOrExport.a.text")) if (importOrExport == Import) { result must include("https://www.gov.uk/government/collections/exchange-rates-for-customs-and-vat") } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala index 93983f2d3..e9efd6fc1 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsRemovedControllerSpec.scala @@ -40,10 +40,10 @@ class GoodsRemovedControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"goodsRemoved.title")) - result must include(messageApi(s"goodsRemoved.heading")) - result must include(messageApi(s"goodsRemoved.p1")) - result must include(messageApi(s"goodsRemoved.link")) + result must include(messages(s"goodsRemoved.title")) + result must include(messages(s"goodsRemoved.heading")) + result must include(messages(s"goodsRemoved.p1")) + result must include(messages(s"goodsRemoved.link")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala index 037a2d669..150e2ae7f 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsTypeControllerSpec.scala @@ -58,9 +58,9 @@ class GoodsTypeControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"goodsType.$journeyType.title")) - result must include(messageApi(s"goodsType.$journeyType.heading")) - result must include(messageApi("goodsType.p")) + result must include(messages(s"goodsType.$journeyType.title")) + result must include(messages(s"goodsType.$journeyType.heading")) + result must include(messages("goodsType.p")) } } @@ -105,10 +105,10 @@ class GoodsTypeControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi(s"goodsType.$journeyType.title")) - result must include(messageApi(s"goodsType.$journeyType.heading")) - result must include(messageApi("goodsType.p")) + result must include(messages("error.summary.title")) + result must include(messages(s"goodsType.$journeyType.title")) + result must include(messages(s"goodsType.$journeyType.heading")) + result must include(messages("goodsType.p")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala index 8012b32e6..b23c7d846 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/GoodsVatRateControllerSpec.scala @@ -97,7 +97,7 @@ class GoodsVatRateControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) result must include(messages("goodsVatRate.title", "clothes")) result must include(messages("goodsVatRate.heading", "clothes")) } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala index 19226a3a0..b4ca71046 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ImportExportChoiceControllerSpec.scala @@ -54,11 +54,11 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("importExportChoice.header")) - result must include(messageApi("importExportChoice.title")) - result must include(messageApi("importExportChoice.MakeImport")) - result must include(messageApi("importExportChoice.MakeExport")) - result must include(messageApi("importExportChoice.AddToExisting")) + result must include(messages("importExportChoice.header")) + result must include(messages("importExportChoice.title")) + result must include(messages("importExportChoice.MakeImport")) + result must include(messages("importExportChoice.MakeExport")) + result must include(messages("importExportChoice.AddToExisting")) } } @@ -122,9 +122,9 @@ class ImportExportChoiceControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi("importExportChoice.header")) - result must include(messageApi("importExportChoice.error.required")) + result must include(messages("error.summary.title")) + result must include(messages("importExportChoice.header")) + result must include(messages("importExportChoice.error.required")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala index 8eca62301..945fbb4f6 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/JourneyDetailsControllerSpec.scala @@ -56,11 +56,11 @@ class JourneyDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("journeyDetails.title")) - result must include(messageApi("journeyDetails.heading")) - result must include(messageApi(s"journeyDetails.port.$importOrExport.label")) - result must include(messageApi("journeyDetails.port.hint")) - result must include(messageApi(s"journeyDetails.dateOfTravel.$importOrExport.label")) + result must include(messages("journeyDetails.title")) + result must include(messages("journeyDetails.heading")) + result must include(messages(s"journeyDetails.port.$importOrExport.label")) + result must include(messages("journeyDetails.port.hint")) + result must include(messages(s"journeyDetails.dateOfTravel.$importOrExport.label")) } } @@ -102,11 +102,11 @@ class JourneyDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("journeyDetails.title")) - result must include(messageApi("journeyDetails.heading")) - result must include(messageApi(s"journeyDetails.port.$importOrExport.label")) - result must include(messageApi("journeyDetails.port.hint")) - result must include(messageApi(s"journeyDetails.dateOfTravel.$importOrExport.label")) + result must include(messages("journeyDetails.title")) + result must include(messages("journeyDetails.heading")) + result must include(messages(s"journeyDetails.port.$importOrExport.label")) + result must include(messages("journeyDetails.port.hint")) + result must include(messages(s"journeyDetails.dateOfTravel.$importOrExport.label")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala index e77510dea..b44415c72 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/KeepAliveControllerSpec.scala @@ -66,10 +66,10 @@ class KeepAliveControllerSpec extends DeclarationJourneyControllerSpec with Core status(eventualResult) mustBe OK - result must include(messageApi(s"timeOut.title")) - result must include(messageApi(s"timeOut.title")) - result must include(messageApi(s"timeOut.guidance")) - result must include(messageApi(s"timeOut.restart.p")) + result must include(messages(s"timeOut.title")) + result must include(messages(s"timeOut.title")) + result must include(messages(s"timeOut.guidance")) + result must include(messages(s"timeOut.restart.p")) result must include(s"""href="https://www.gov.uk/" class="govuk-header__link""") // note: footer also has gov.uk } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala index 14790dfbc..d5246c871 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NewOrExistingControllerSpec.scala @@ -52,9 +52,9 @@ class NewOrExistingControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"newOrExisting.title")) - result must include(messageApi(s"newOrExisting.heading")) - result must include(messageApi(s"service.name.${importOrExport.entryName}.a.href")) + result must include(messages(s"newOrExisting.title")) + result must include(messages(s"newOrExisting.heading")) + result must include(messages(s"service.name.${importOrExport.entryName}.a.href")) } } @@ -111,7 +111,7 @@ class NewOrExistingControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala index 718389442..15daa0ea1 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/NoDeclarationNeededControllerSpec.scala @@ -41,9 +41,9 @@ class NoDeclarationNeededControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"noDeclarationNeeded.title")) - result must include(messageApi(s"noDeclarationNeeded.heading")) - result must include(messageApi(s"noDeclarationNeeded.p")) + result must include(messages(s"noDeclarationNeeded.title")) + result must include(messages(s"noDeclarationNeeded.heading")) + result must include(messages(s"noDeclarationNeeded.p")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala index 7b74bc982..c25b08c5b 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/PurchaseDetailsControllerSpec.scala @@ -112,7 +112,7 @@ class PurchaseDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) result must include(messages("purchaseDetails.title", "clothes")) result must include(messages("purchaseDetails.heading", "clothes")) } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala index e97b7efa5..f446f89bd 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/RetrieveDeclarationControllerSpec.scala @@ -62,15 +62,15 @@ class RetrieveDeclarationControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi(s"retrieveDeclaration.title")) - result must include(messageApi(s"retrieveDeclaration.heading")) - result must include(messageApi(s"retrieveDeclaration.p")) + result must include(messages(s"retrieveDeclaration.title")) + result must include(messages(s"retrieveDeclaration.heading")) + result must include(messages(s"retrieveDeclaration.p")) - result must include(messageApi(s"retrieveDeclaration.mibReference.label")) - result must include(messageApi(s"retrieveDeclaration.mibReference.hint")) + result must include(messages(s"retrieveDeclaration.mibReference.label")) + result must include(messages(s"retrieveDeclaration.mibReference.hint")) - result must include(messageApi(s"retrieveDeclaration.eori.label")) - result must include(messageApi(s"retrieveDeclaration.eori.hint")) + result must include(messages(s"retrieveDeclaration.eori.label")) + result must include(messages(s"retrieveDeclaration.eori.hint")) } } } @@ -124,8 +124,8 @@ class RetrieveDeclarationControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi(s"retrieveDeclaration.mibReference.error.invalid")) - result must include(messageApi(s"retrieveDeclaration.eori.error.invalid")) + result must include(messages(s"retrieveDeclaration.mibReference.error.invalid")) + result must include(messages(s"retrieveDeclaration.eori.error.invalid")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala index dc7c73595..93127699d 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ReviewGoodsControllerSpec.scala @@ -82,10 +82,10 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr status(eventualResult) mustBe OK if (importOrExport == Import) { - result must include(messageApi("reviewGoods.list.vatRate")) - result must include(messageApi("reviewGoods.list.producedInEu")) + result must include(messages("reviewGoods.list.vatRate")) + result must include(messages("reviewGoods.list.producedInEu")) } else { - result must include(messageApi("reviewGoods.list.destination")) + result must include(messages("reviewGoods.list.destination")) } } @@ -163,9 +163,9 @@ class ReviewGoodsControllerSpec extends DeclarationJourneyControllerSpec with Pr val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi("reviewGoods.New.title")) - result must include(messageApi("reviewGoods.New.heading")) + result must include(messages("error.summary.title")) + result must include(messages("reviewGoods.New.title")) + result must include(messages("reviewGoods.New.heading")) } s"redirect to CannotAccessPage when no ThresholdAllowance is received from mibService for $importOrExport" in { diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala index a7f075376..d0b6daf0c 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/SearchGoodsCountryControllerSpec.scala @@ -90,7 +90,7 @@ class SearchGoodsCountryControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) result must include(messages(s"searchGoodsCountry.title", "test good")) result must include(messages(s"searchGoodsCountry.heading", "test good")) } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala index 45a7a8d88..4d01a1695 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/TravellerDetailsControllerSpec.scala @@ -49,11 +49,11 @@ class TravellerDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("travellerDetails.title")) - result must include(messageApi("travellerDetails.heading")) - result must include(messageApi("travellerDetails.hint")) - result must include(messageApi("travellerDetails.firstName")) - result must include(messageApi("travellerDetails.lastName")) + result must include(messages("travellerDetails.title")) + result must include(messages("travellerDetails.heading")) + result must include(messages("travellerDetails.hint")) + result must include(messages("travellerDetails.firstName")) + result must include(messages("travellerDetails.lastName")) } } @@ -85,13 +85,13 @@ class TravellerDetailsControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("travellerDetails.title")) - result must include(messageApi("travellerDetails.heading")) - result must include(messageApi("travellerDetails.hint")) - result must include(messageApi("travellerDetails.firstName")) - result must include(messageApi("travellerDetails.lastName")) - result must include(messageApi("travellerDetails.firstName.error.required")) - result must include(messageApi("travellerDetails.lastName.error.required")) + result must include(messages("travellerDetails.title")) + result must include(messages("travellerDetails.heading")) + result must include(messages("travellerDetails.hint")) + result must include(messages("travellerDetails.firstName")) + result must include(messages("travellerDetails.lastName")) + result must include(messages("travellerDetails.firstName.error.required")) + result must include(messages("travellerDetails.lastName.error.required")) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala index 52b2c7ea0..53a39c99e 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/ValueWeightOfGoodsControllerSpec.scala @@ -52,8 +52,8 @@ class ValueWeightOfGoodsControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe OK - result must include(messageApi("valueWeightOfGoods.GreatBritain.title", thresholdValueInUI)) - result must include(messageApi("valueWeightOfGoods.GreatBritain.heading", thresholdValueInUI)) + result must include(messages("valueWeightOfGoods.GreatBritain.title", thresholdValueInUI)) + result must include(messages("valueWeightOfGoods.GreatBritain.heading", thresholdValueInUI)) } } @@ -87,9 +87,9 @@ class ValueWeightOfGoodsControllerSpec extends DeclarationJourneyControllerSpec val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) - result must include(messageApi("valueWeightOfGoods.GreatBritain.title", thresholdValueInUI)) - result must include(messageApi("valueWeightOfGoods.GreatBritain.heading", thresholdValueInUI)) + result must include(messages("error.summary.title")) + result must include(messages("valueWeightOfGoods.GreatBritain.title", thresholdValueInUI)) + result must include(messages("valueWeightOfGoods.GreatBritain.heading", thresholdValueInUI)) } } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala index e1b44598d..db2a979eb 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleRegistrationNumberControllerSpec.scala @@ -84,7 +84,7 @@ class VehicleRegistrationNumberControllerSpec extends DeclarationJourneyControll val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) result must include(messages("vehicleRegistrationNumber.error.required")) } } diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala index 99745b18d..767155223 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/controllers/VehicleSizeControllerSpec.scala @@ -90,7 +90,7 @@ class VehicleSizeControllerSpec extends DeclarationJourneyControllerSpec { val result = contentAsString(eventualResult) status(eventualResult) mustBe BAD_REQUEST - result must include(messageApi("error.summary.title")) + result must include(messages("error.summary.title")) result must include(messages(s"vehicleSize.$importOrExport.title")) result must include(messages(s"vehicleSize.$importOrExport.heading")) result must include(messages("vehicleSize.hint")) diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/service/AuditorSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/service/AuditorSpec.scala index 24dc7daca..8aafc102a 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggage/service/AuditorSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggage/service/AuditorSpec.scala @@ -19,7 +19,6 @@ package uk.gov.hmrc.merchandiseinbaggage.service import org.mockito.ArgumentMatchers.any import org.mockito.Mockito.{mock, when} import org.scalatest.concurrent.ScalaFutures -import play.api.i18n.MessagesApi import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.merchandiseinbaggage.{BaseSpec, CoreTestData} import uk.gov.hmrc.play.audit.http.connector.AuditConnector @@ -30,8 +29,7 @@ import scala.concurrent.Future class AuditorSpec extends BaseSpec with CoreTestData with ScalaFutures { - private val failed: Failure = Failure("failed") - private val aMessagesApi: MessagesApi = mock(classOf[MessagesApi]) + private val failed: Failure = Failure("failed") private implicit val aHeaderCarrier: HeaderCarrier = HeaderCarrier() @@ -46,7 +44,6 @@ class AuditorSpec extends BaseSpec with CoreTestData with ScalaFutures { val auditService = new Auditor { override val auditConnector: AuditConnector = mockAuditConnector - override val messagesApi: MessagesApi = aMessagesApi } auditService.auditDeclaration(declaration).futureValue mustBe a[Unit] diff --git a/test/uk/gov/hmrc/merchandiseinbaggage/utils/MessagesSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggage/utils/MessagesSpec.scala new file mode 100644 index 000000000..34e4ee976 --- /dev/null +++ b/test/uk/gov/hmrc/merchandiseinbaggage/utils/MessagesSpec.scala @@ -0,0 +1,161 @@ +/* + * Copyright 2024 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package uk.gov.hmrc.merchandiseinbaggage.utils + +import play.api.Logging +import uk.gov.hmrc.merchandiseinbaggage.BaseSpecWithApplication + +import scala.util.matching.Regex + +class MessagesSpec extends BaseSpecWithApplication with Logging { + + private val displayLine: String = "\n" + ("@" * 42) + "\n" + private val defaultMessages: Map[String, String] = getExpectedMessages("default") + private val welshMessages: Map[String, String] = getExpectedMessages("cy") + + private val adminOnlyMessages = Set( + "checkYourAnswers.sendDeclaration.acknowledgement.AD", + "enterEmail.email.optional", + "importExportChoice.AddToExisting", + "importExportChoice.MakeExport", + "importExportChoice.MakeImport", + "importExportChoice.error.required", + "importExportChoice.header", + "importExportChoice.title", + "invalidRequest.ad" + ) + + "MessagesSpec" should { + "have the correct message configs" in { + messagesApi.messages.size mustBe 4 + messagesApi.messages.keys must contain theSameElementsAs Vector("en", "cy", "default", "default.play") + } + + "have messages for default and cy only" in { + val englishMessageCount = messagesApi.messages("default").size + val welshMessageCount = messagesApi.messages("cy").size + + welshMessageCount mustBe (englishMessageCount - adminOnlyMessages.size) + } + } + + "All message files" should { + "have the same set of keys" in { + val welshKeys = welshMessages.keySet + val enKeys = defaultMessages.keySet -- adminOnlyMessages + withClue(mismatchingKeys(enKeys, welshKeys)) { + assert(welshKeys equals enKeys) + } + } + "have a non-empty message for each key" in { + assertNonEmptyValuesForDefaultMessages() + assertNonEmptyValuesForWelshMessages() + } + "have no unescaped single quotes in value" in { + assertCorrectUseOfQuotesForDefaultMessages() + assertCorrectUseOfQuotesForWelshMessages() + } + "have a resolvable message for keys which take args" in { + val englishWithArgsMsgKeys = defaultMessages.collect { + case (messagesKey, messagesValue) if countArgs(messagesValue) > 0 => messagesKey + } + val welshWithArgsMsgKeys = welshMessages.collect { + case (messagesKey, messagesValue) if countArgs(messagesValue) > 0 => messagesKey + } + val missingFromEnglish = englishWithArgsMsgKeys.toList diff welshWithArgsMsgKeys.toList + val missingFromWelsh = welshWithArgsMsgKeys.toList diff englishWithArgsMsgKeys.toList + missingFromEnglish.foreach { messagesKey => + logger.error(s"Key which has arguments in English but not in Welsh: $messagesKey") + } + missingFromWelsh.foreach { messagesKey => + logger.error(s"Key which has arguments in Welsh but not in English: $messagesKey") + } + englishWithArgsMsgKeys.size mustBe welshWithArgsMsgKeys.size + } + "have the same args in the same order for all keys which take args" in { + val englishWithArgsMsgKeysAndArgList = defaultMessages collect { + case (messageKey, messageValue) if countArgs(messageValue) > 0 => (messageKey, listArgs(messageValue)) + } + val welshWithArgsMsgKeysAndArgList = welshMessages collect { + case (messageKey, messageValue) if countArgs(messageValue) > 0 => (messageKey, listArgs(messageValue)) + } + val mismatchedArgSequences = englishWithArgsMsgKeysAndArgList collect { + case (messageKey, engArgSeq) if engArgSeq != welshWithArgsMsgKeysAndArgList(messageKey) => + (messageKey, engArgSeq, welshWithArgsMsgKeysAndArgList(messageKey)) + } + mismatchedArgSequences foreach { case (key, engArgSeq, welshArgSeq) => + logger.error( + s"key which has different arguments or order of arguments between English and Welsh:" + + s" $key -- English arg seq=$engArgSeq and Welsh arg seq=$welshArgSeq" + ) + } + + mismatchedArgSequences must be(empty) + } + } + val MatchSingleQuoteOnly: Regex = """\w+'{1}\w+""".r + val MatchBacktickQuoteOnly: Regex = """`+""".r + + private def countArgs(msg: String) = toArgArray(msg).length + + private def toArgArray(msg: String) = msg.split("[{}]").map(_.trim()).filter(isInteger) + + private def isInteger(s: String): Boolean = s forall Character.isDigit + + private def listArgs(msg: String) = toArgArray(msg).mkString + + private def assertNonEmptyValuesForDefaultMessages(): Unit = + assertNonEmptyNonTemporaryValues("Default", defaultMessages) + + private def assertNonEmptyValuesForWelshMessages(): Unit = assertNonEmptyNonTemporaryValues("Welsh", welshMessages) + + private def assertNonEmptyNonTemporaryValues(label: String, messages: Map[String, String]): Unit = messages.foreach { + case (key: String, value: String) => + withClue(s"In $label, there is an empty value for the key:[$key][$value]") { + value.trim.isEmpty mustBe false + } + } + + private def assertCorrectUseOfQuotesForDefaultMessages(): Unit = assertCorrectUseOfQuotes("Default", defaultMessages) + + private def assertCorrectUseOfQuotes(label: String, messages: Map[String, String]): Unit = messages.foreach { + case (key: String, value: String) => + withClue(s"In $label, there is an unescaped or invalid quote:[$key][$value]") { + MatchSingleQuoteOnly.findFirstIn(value).isDefined mustBe false + MatchBacktickQuoteOnly.findFirstIn(value).isDefined mustBe false + } + } + + private def assertCorrectUseOfQuotesForWelshMessages(): Unit = assertCorrectUseOfQuotes("Welsh", welshMessages) + + private def getExpectedMessages(languageCode: String) = + messagesApi.messages.getOrElse(languageCode, throw new Exception(s"Missing messages for $languageCode")) + + private def mismatchingKeys(defaultKeySet: Set[String], welshKeySet: Set[String]) = { + val test1 = + listMissingMessageKeys("The following message keys are missing from Welsh Set:", defaultKeySet.diff(welshKeySet)) + val test2 = listMissingMessageKeys( + "The following message keys are missing from English Set:", + welshKeySet.diff(defaultKeySet) + ) + + test1 ++ test2 + } + + private def listMissingMessageKeys(header: String, missingKeys: Set[String]) = + missingKeys.toList.sorted.mkString(header + displayLine, "\n", displayLine) +}