diff --git a/app/uk/gov/hmrc/pillar2/models/financial/TransactionHistory.scala b/app/uk/gov/hmrc/pillar2/models/financial/TransactionHistory.scala index cec9e2b..bbbfc71 100644 --- a/app/uk/gov/hmrc/pillar2/models/financial/TransactionHistory.scala +++ b/app/uk/gov/hmrc/pillar2/models/financial/TransactionHistory.scala @@ -17,9 +17,9 @@ package uk.gov.hmrc.pillar2.models.financial import play.api.libs.json.Json +import play.api.libs.json.OFormat import java.time.LocalDate -import play.api.libs.json.OFormat final case class FinancialHistory(date: LocalDate, paymentType: String, amountPaid: BigDecimal, amountRepaid: BigDecimal) diff --git a/build.sbt b/build.sbt index 358fc12..55c4ffe 100755 --- a/build.sbt +++ b/build.sbt @@ -14,28 +14,31 @@ ThisBuild / majorVersion := 0 lazy val microservice = Project(appName, file(".")) .enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin) .settings( - ScoverageKeys.coverageExcludedFiles := - ";com.kenshoo.play.metrics.*;.*definition.*;prod.*;testOnlyDoNotUseInAppConf.*;.*stubs.*;.*models.*;" + - "app.*;.*BuildInfo.*;.*Routes.*;.*repositories.*;.*package.*;.*controllers.test.*;.*services.test.*;.*metrics.*", - ScoverageKeys.coverageMinimumStmtTotal := 80, - ScoverageKeys.coverageFailOnMinimum := true, - ScoverageKeys.coverageHighlighting := true, - PlayKeys.playDefaultPort := 10051, - Compile / scalafmtOnCompile := true, - Test / scalafmtOnCompile := true, + ScoverageKeys.coverageExcludedFiles := + ";com.kenshoo.play.metrics.*;.*definition.*;prod.*;testOnlyDoNotUseInAppConf.*;.*stubs.*;.*models.*;" + + "app.*;.*BuildInfo.*;.*Routes.*;.*repositories.*;.*package.*;.*controllers.test.*;.*services.test.*;.*metrics.*", + ScoverageKeys.coverageMinimumStmtTotal := 80, + ScoverageKeys.coverageFailOnMinimum := true, + ScoverageKeys.coverageHighlighting := true, + PlayKeys.playDefaultPort := 10051, + Compile / scalafmtOnCompile := true, + Test / scalafmtOnCompile := true, libraryDependencies ++= AppDependencies.compile ++ AppDependencies.test, // https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html // suppress warnings in generated routes files - scalacOptions += "-Wconf:src=routes/.*:s", + scalacOptions += "-Wconf:src=routes/.*:s" ) .settings( Compile / unmanagedResourceDirectories += baseDirectory.value / "resources", Test / unmanagedSourceDirectories := (Test / baseDirectory)(base => Seq(base / "test", base / "test-common")).value, - Test / unmanagedResourceDirectories := Seq(baseDirectory.value / "test-resources"), + Test / unmanagedResourceDirectories := Seq(baseDirectory.value / "test-resources") ) .settings(resolvers += Resolver.jcenterRepo) .settings(CodeCoverageSettings.settings *) +addCommandAlias("prePrChecks", ";scalafmtCheckAll;scalafmtSbtCheck;scalafixAll --check") +addCommandAlias("lint", ";scalafmtAll;scalafmtSbt;scalafixAll") + lazy val it = project .enablePlugins(play.sbt.PlayScala) .dependsOn(microservice % "test->test") @@ -47,4 +50,4 @@ inThisBuild( semanticdbEnabled := true, semanticdbVersion := scalafixSemanticdb.revision ) -) \ No newline at end of file +) diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index a6cbacb..c80a6a6 100755 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -10,22 +10,22 @@ object AppDependencies { private val hmrcMongoVersion = "1.7.0" val compile: Seq[ModuleID] = Seq( - "uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapVersion, - "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % hmrcMongoVersion, - "uk.gov.hmrc" %% "crypto-json-play-30" % "8.0.0" + "uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapVersion, + "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % hmrcMongoVersion, + "uk.gov.hmrc" %% "crypto-json-play-30" % "8.0.0" ) val test: Seq[ModuleID] = Seq( - "org.scalatest" %% "scalatest" % "3.2.18" , - "uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapVersion, - "uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % hmrcMongoVersion, - "org.mockito" % "mockito-core" % "5.11.0", - "org.scalatestplus" %% "mockito-4-11" % "3.2.18.0", + "org.scalatest" %% "scalatest" % "3.2.18", + "uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapVersion, + "uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % hmrcMongoVersion, + "org.mockito" % "mockito-core" % "5.11.0", + "org.scalatestplus" %% "mockito-4-11" % "3.2.18.0", "org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2", - "wolfendale" %% "scalacheck-gen-regexp" % "0.1.2", - "com.github.tomakehurst" % "wiremock-standalone" % "3.0.1", - "com.softwaremill.diffx" %% "diffx-core" % "0.9.0" , - "com.softwaremill.diffx" %% "diffx-scalatest" % "0.9.0" + "wolfendale" %% "scalacheck-gen-regexp" % "0.1.2", + "com.github.tomakehurst" % "wiremock-standalone" % "3.0.1", + "com.softwaremill.diffx" %% "diffx-core" % "0.9.0", + "com.softwaremill.diffx" %% "diffx-scalatest" % "0.9.0" ).map(_ % Test) val it: Seq[ModuleID] = Seq( diff --git a/test/uk/gov/hmrc/pillar2/connectors/ObligationConnectorSpec.scala b/test/uk/gov/hmrc/pillar2/connectors/ObligationConnectorSpec.scala index 39f98bb..412b3eb 100644 --- a/test/uk/gov/hmrc/pillar2/connectors/ObligationConnectorSpec.scala +++ b/test/uk/gov/hmrc/pillar2/connectors/ObligationConnectorSpec.scala @@ -1,3 +1,19 @@ +/* + * 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.pillar2.connectors import com.github.tomakehurst.wiremock.client.WireMock.{aResponse, get, urlEqualTo} diff --git a/test/uk/gov/hmrc/pillar2/controllers/ObligationControllerSpec.scala b/test/uk/gov/hmrc/pillar2/controllers/ObligationControllerSpec.scala index 9286af7..04f465d 100644 --- a/test/uk/gov/hmrc/pillar2/controllers/ObligationControllerSpec.scala +++ b/test/uk/gov/hmrc/pillar2/controllers/ObligationControllerSpec.scala @@ -1,3 +1,19 @@ +/* + * 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.pillar2.controllers import org.mockito.ArgumentMatchers.any diff --git a/test/uk/gov/hmrc/pillar2/generators/ModelGenerators.scala b/test/uk/gov/hmrc/pillar2/generators/ModelGenerators.scala index b767686..dfef50d 100644 --- a/test/uk/gov/hmrc/pillar2/generators/ModelGenerators.scala +++ b/test/uk/gov/hmrc/pillar2/generators/ModelGenerators.scala @@ -19,6 +19,7 @@ package uk.gov.hmrc.pillar2.generators import org.scalacheck.Arbitrary.arbitrary import org.scalacheck.{Arbitrary, Gen} import play.api.libs.json.{JsObject, JsValue, Json} +import uk.gov.hmrc.pillar2.models._ import uk.gov.hmrc.pillar2.models.audit._ import uk.gov.hmrc.pillar2.models.grs._ import uk.gov.hmrc.pillar2.models.hods._ @@ -28,7 +29,6 @@ import uk.gov.hmrc.pillar2.models.hods.subscription.common._ import uk.gov.hmrc.pillar2.models.hods.subscription.request.RequestDetail import uk.gov.hmrc.pillar2.models.registration._ import uk.gov.hmrc.pillar2.models.subscription.{ReadSubscriptionRequestParameters, SubscriptionAddress, SubscriptionRequestParameters} -import uk.gov.hmrc.pillar2.models.{AccountStatus, AccountingPeriod, AccountingPeriodAmend, NonUKAddress, RowStatus, UKAddress, UserAnswers} import java.time.{Instant, LocalDate} diff --git a/test/uk/gov/hmrc/pillar2/helpers/AllMocks.scala b/test/uk/gov/hmrc/pillar2/helpers/AllMocks.scala index d9adf07..a7036ed 100644 --- a/test/uk/gov/hmrc/pillar2/helpers/AllMocks.scala +++ b/test/uk/gov/hmrc/pillar2/helpers/AllMocks.scala @@ -23,11 +23,11 @@ import org.scalatestplus.mockito.MockitoSugar import uk.gov.hmrc.auth.core.{AuthConnector, AuthorisedFunctions} import uk.gov.hmrc.http.HttpClient import uk.gov.hmrc.pillar2.config.AppConfig -import uk.gov.hmrc.pillar2.connectors.{FinancialDataConnector, ObligationConnector, RegistrationConnector, RepaymentConnector, SubscriptionConnector} +import uk.gov.hmrc.pillar2.connectors._ import uk.gov.hmrc.pillar2.controllers.auth.AuthAction import uk.gov.hmrc.pillar2.repositories.RegistrationCacheRepository +import uk.gov.hmrc.pillar2.service._ import uk.gov.hmrc.pillar2.service.audit.AuditService -import uk.gov.hmrc.pillar2.service.{FinancialService, RegistrationService, RepaymentService, SubscriptionService} import uk.gov.hmrc.pillar2.utils.countryOptions.CountryOptions import uk.gov.hmrc.play.audit.http.connector.AuditConnector