Skip to content

Commit

Permalink
Merge pull request #50 from hmrc/API-3321
Browse files Browse the repository at this point in the history
API-3321: library upgrade and other improvements
  • Loading branch information
gokyo authored Jul 20, 2018
2 parents 58aec72 + 9982b3c commit 6000e17
Show file tree
Hide file tree
Showing 25 changed files with 155 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package uk.gov.hmrc.apisubscriptionfields.service

import javax.inject.{Inject, Singleton}

import play.api.Logger
import uk.gov.hmrc.apisubscriptionfields.model._
import uk.gov.hmrc.apisubscriptionfields.repository.{FieldsDefinition, FieldsDefinitionRepository}

Expand Down
28 changes: 17 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import scala.language.postfixOps

val compile = Seq(
ws,
"uk.gov.hmrc" %% "microservice-bootstrap" % "6.17.0",
"uk.gov.hmrc" %% "microservice-bootstrap" % "6.18.0",
"uk.gov.hmrc" %% "play-reactivemongo" % "6.2.0",
"uk.gov.hmrc" %% "play-hmrc-api" % "2.0.0"
)
Expand All @@ -54,10 +54,10 @@ lazy val plugins: Seq[Plugins] = Seq.empty
lazy val playSettings: Seq[Setting[_]] = Seq.empty

lazy val AcceptanceTest = config("acceptance") extend Test
val testConfig = Seq(AcceptanceTest, Test)

lazy val IntegrationTest = config("it") extend Test

val testConfig = Seq(AcceptanceTest, Test, IntegrationTest)

lazy val microservice = Project(appName, file("."))
.enablePlugins(Seq(PlayScala, SbtAutoBuildPlugin, SbtGitVersioning, SbtDistributablesPlugin) ++ plugins: _*)
.configs(testConfig: _*)
Expand All @@ -73,31 +73,33 @@ lazy val microservice = Project(appName, file("."))
evictionWarningOptions in update := EvictionWarningOptions.default.withWarnScalaVersionEviction(false)
)
.settings(scoverageSettings)
.configs(IntegrationTest)
.settings(inConfig(IntegrationTest)(Defaults.itSettings): _*)
.settings(Defaults.itSettings)
.settings(
testOptions in IntegrationTest := Seq(Tests.Filter(integrationFilter)),
Keys.fork in IntegrationTest := false,
unmanagedSourceDirectories in IntegrationTest <<= (baseDirectory in IntegrationTest) (base => Seq(base / "test" / "it")),
addTestReportOption(IntegrationTest, "integration-reports"),
testGrouping in IntegrationTest := oneForkedJvmPerTest((definedTests in IntegrationTest).value),
parallelExecution in IntegrationTest := false)

lazy val unitTestSettings =
inConfig(Test)(Defaults.testTasks) ++
inConfig(Test)(Defaults.testSettings) ++
Seq(
testOptions in Test := Seq(Tests.Filter(unitFilter)),
unmanagedSourceDirectories in Test := Seq(
baseDirectory.value / "test" / "unit",
baseDirectory.value / "test" / "unit",
baseDirectory.value / "test" / "util"
),
fork in Test := false,
addTestReportOption(Test, "test-reports")
)

lazy val acceptanceTestSettings =
inConfig(AcceptanceTest)(Defaults.testTasks) ++
inConfig(AcceptanceTest)(Defaults.testSettings) ++
Seq(
testOptions in AcceptanceTest := Seq(Tests.Filter(acceptanceFilter)),
unmanagedSourceDirectories in AcceptanceTest := Seq(
baseDirectory.value / "test" / "acceptance",
baseDirectory.value / "test" / "acceptance",
baseDirectory.value / "test" / "util"
),
fork in AcceptanceTest := false,
Expand All @@ -113,7 +115,11 @@ lazy val scoverageSettings: Seq[Setting[_]] = Seq(
parallelExecution in Test := false
)

def oneForkedJvmPerTest(tests: Seq[TestDefinition]) =
def unitFilter(name: String): Boolean = !integrationFilter(name) && !acceptanceFilter(name)
def integrationFilter(name: String): Boolean = name contains "integration"
def acceptanceFilter(name: String): Boolean = name contains "acceptance"

def oneForkedJvmPerTest(tests: Seq[TestDefinition]): Seq[Group] =
tests map {
test => Group(test.name, Seq(test), SubProcess(ForkOptions(runJVMOptions = Seq("-Dtest.name=" + test.name))))
}
Expand All @@ -123,6 +129,6 @@ def forkedJvmPerTestConfig(tests: Seq[TestDefinition], packages: String*): Seq[G
case (packg, theTests) => Group(packg, theTests, SubProcess(ForkOptions()))
} toSeq

def onPackageName(rootPackage: String): (String => Boolean) = {
def onPackageName(rootPackage: String): String => Boolean = {
testName => testName startsWith rootPackage
}
7 changes: 4 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ resolvers += Resolver.url("hmrc-sbt-plugin-releases", url("https://dl.bintray.co

resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.8.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "0.9.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.0.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.12.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "0.10.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.1.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.12")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
99 changes: 99 additions & 0 deletions scalastyle-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<scalastyle>
<name>Scalastyle standard configuration</name>
<check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
<parameters>
<parameter name="maxFileLength"><![CDATA[800]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="false"/>
<check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
<parameters>
<parameter name="maxLineLength"><![CDATA[160]]></parameter>
<parameter name="tabSize"><![CDATA[4]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
<parameters>
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
<parameters>
<parameter name="maxParameters"><![CDATA[8]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="true">
<parameters>
<parameter name="ignore"><![CDATA[-1,0,1,2,3]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[println]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
<parameters>
<parameter name="maxTypes"><![CDATA[30]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
<parameters>
<parameter name="maximum"><![CDATA[10]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"/>
<check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
<parameters>
<parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
<parameter name="doubleLineAllowed"><![CDATA[true]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
<parameters>
<parameter name="maxLength"><![CDATA[50]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
<parameters>
<parameter name="maxMethods"><![CDATA[30]]></parameter>
</parameters>
</check>
<check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="false"/>
<check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="false"/>
<check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"/>
</scalastyle>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 HM Revenue & Customs
* Copyright 2018 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.
Expand All @@ -14,6 +14,8 @@
* limitations under the License.
*/

package uk.gov.hmrc.apisubscriptionfields.acceptance

import java.util.UUID

import org.scalatest._
Expand All @@ -24,9 +26,9 @@ import play.api.libs.json.Json
import play.api.mvc.{AnyContentAsEmpty, AnyContentAsJson}
import play.api.test.FakeRequest
import play.modules.reactivemongo.MongoDbConnection
import uk.gov.hmrc.apisubscriptionfields.model._
import uk.gov.hmrc.apisubscriptionfields.model.JsonFormatters._
import util.{ExternalServicesConfig, RequestHeaders}
import uk.gov.hmrc.apisubscriptionfields.model._
import uk.gov.hmrc.apisubscriptionfields.util.{ExternalServicesConfig, RequestHeaders}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 HM Revenue & Customs
* Copyright 2018 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.
Expand All @@ -14,14 +14,14 @@
* limitations under the License.
*/

package acceptance
package uk.gov.hmrc.apisubscriptionfields.acceptance

import org.scalatest.OptionValues
import play.api.Logger
import play.api.mvc._
import play.api.test.Helpers._
import uk.gov.hmrc.apisubscriptionfields.model._
import util.{FieldsDefinitionTestData, SubscriptionFieldsTestData}
import uk.gov.hmrc.apisubscriptionfields.util.{FieldsDefinitionTestData, SubscriptionFieldsTestData}

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 HM Revenue & Customs
* Copyright 2018 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.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package acceptance
package uk.gov.hmrc.apisubscriptionfields.acceptance

import org.scalatest.OptionValues
import play.api.Logger
Expand All @@ -23,7 +23,7 @@ import play.api.mvc._
import play.api.test.Helpers._
import uk.gov.hmrc.apisubscriptionfields.model.ErrorCode.{INVALID_REQUEST_PAYLOAD, NOT_FOUND_CODE}
import uk.gov.hmrc.apisubscriptionfields.model.JsErrorResponse
import util.SubscriptionFieldsTestData
import uk.gov.hmrc.apisubscriptionfields.util.SubscriptionFieldsTestData

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 HM Revenue & Customs
* Copyright 2018 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.
Expand All @@ -14,13 +14,13 @@
* limitations under the License.
*/

package acceptance
package uk.gov.hmrc.apisubscriptionfields.acceptance

import org.scalatest.OptionValues
import play.api.mvc._
import play.api.test.Helpers._
import uk.gov.hmrc.apisubscriptionfields.model._
import util.{FieldsDefinitionTestData, SubscriptionFieldsTestData}
import uk.gov.hmrc.apisubscriptionfields.util.{FieldsDefinitionTestData, SubscriptionFieldsTestData}

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 HM Revenue & Customs
* Copyright 2018 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.
Expand All @@ -14,15 +14,15 @@
* limitations under the License.
*/

package acceptance
package uk.gov.hmrc.apisubscriptionfields.acceptance

import org.scalatest.OptionValues
import play.api.libs.json.Json
import play.api.mvc._
import play.api.test.Helpers._
import uk.gov.hmrc.apisubscriptionfields.model.ErrorCode.{INVALID_REQUEST_PAYLOAD, NOT_FOUND_CODE}
import uk.gov.hmrc.apisubscriptionfields.model.JsErrorResponse
import util.SubscriptionFieldsTestData
import uk.gov.hmrc.apisubscriptionfields.util.SubscriptionFieldsTestData

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 HM Revenue & Customs
* Copyright 2018 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.
Expand All @@ -14,6 +14,8 @@
* limitations under the License.
*/

package uk.gov.hmrc.apisubscriptionfields.integration

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.client.WireMock._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import play.api.test.Helpers._
import uk.gov.hmrc.apisubscriptionfields.model.JsonFormatters
import uk.gov.hmrc.apisubscriptionfields.service.FieldsDefinitionService
import uk.gov.hmrc.play.test.UnitSpec
import util.FieldsDefinitionTestData
import uk.gov.hmrc.apisubscriptionfields.util.FieldsDefinitionTestData

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import play.api.test._
import uk.gov.hmrc.apisubscriptionfields.model.{BulkFieldsDefinitionsResponse, FieldsDefinitionResponse, JsonFormatters}
import uk.gov.hmrc.apisubscriptionfields.service.FieldsDefinitionService
import uk.gov.hmrc.play.test.UnitSpec
import util.FieldsDefinitionTestData
import uk.gov.hmrc.apisubscriptionfields.util.FieldsDefinitionTestData

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import play.api.test._
import uk.gov.hmrc.apisubscriptionfields.model.{FieldsDefinitionRequest, JsonFormatters}
import uk.gov.hmrc.apisubscriptionfields.service.FieldsDefinitionService
import uk.gov.hmrc.play.test.UnitSpec
import util.FieldsDefinitionTestData
import uk.gov.hmrc.apisubscriptionfields.util.FieldsDefinitionTestData

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import play.api.test.Helpers._
import uk.gov.hmrc.apisubscriptionfields.model.{ApiContext, ApiVersion, ClientId, JsonFormatters}
import uk.gov.hmrc.apisubscriptionfields.service.SubscriptionFieldsService
import uk.gov.hmrc.play.test.UnitSpec
import util.SubscriptionFieldsTestData
import uk.gov.hmrc.apisubscriptionfields.util.SubscriptionFieldsTestData

import scala.concurrent.Future

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import play.api.libs.json.{JsDefined, JsString, Json}
import play.api.mvc._
import play.api.test.Helpers._
import play.api.test._
import uk.gov.hmrc.apisubscriptionfields.controller.SubscriptionFieldsController
import uk.gov.hmrc.apisubscriptionfields.model._
import uk.gov.hmrc.apisubscriptionfields.service.SubscriptionFieldsService
import uk.gov.hmrc.apisubscriptionfields.util.SubscriptionFieldsTestData
import uk.gov.hmrc.play.test.UnitSpec
import util.SubscriptionFieldsTestData

import scala.concurrent.Future

Expand Down
Loading

0 comments on commit 6000e17

Please sign in to comment.