Skip to content

Commit cece68d

Browse files
authored
Merge pull request #62 from hmrc/APIS-5326
APIS-5326
2 parents 05a95ee + dd7c985 commit cece68d

17 files changed

+187
-241
lines changed

app/config/frontendAppConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package config
1818

1919
import javax.inject.{Inject, Singleton}
20-
import play.api.{Configuration, Environment, Mode, Play}
20+
import play.api.{Configuration, Environment}
2121
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig
2222

2323

app/connectors/DelegatedAuthorityConnector.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import models.AppAuthorisation
2323
import uk.gov.hmrc.http._
2424
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig
2525
import uk.gov.hmrc.play.bootstrap.http.HttpClient
26-
26+
import uk.gov.hmrc.http.HttpReads.Implicits._
2727
import scala.concurrent.{ExecutionContext, Future}
28+
import scala.concurrent.Future._
2829

2930
@Singleton
3031
class DelegatedAuthorityConnector @Inject()(servicesConfig: ServicesConfig, http: HttpClient)
@@ -37,15 +38,15 @@ class DelegatedAuthorityConnector @Inject()(servicesConfig: ServicesConfig, http
3738
}
3839

3940
def fetchApplicationAuthority(applicationId: UUID)(implicit hc: HeaderCarrier): Future[AppAuthorisation] = {
40-
http.GET[AppAuthorisation](s"$delegatedAuthorityUrl/authority/granted-application/$applicationId") recover recovery
41+
http.GET[Option[AppAuthorisation]](s"$delegatedAuthorityUrl/authority/granted-application/$applicationId") flatMap(handleNotFound)
4142
}
4243

4344
def revokeApplicationAuthority(applicationId: UUID)(implicit hc: HeaderCarrier): Future[Unit] = {
44-
http.DELETE(s"$delegatedAuthorityUrl/authority/granted-application/$applicationId") map (_ => ()) recover recovery
45+
http.DELETE[Option[Unit]](s"$delegatedAuthorityUrl/authority/granted-application/$applicationId") flatMap(handleNotFound _)
4546
}
4647

47-
private def recovery: PartialFunction[Throwable, Nothing] = {
48-
case _: NotFoundException => throw new AuthorityNotFound
48+
def handleNotFound[T](o: Option[T]): Future[T] = {
49+
o.fold[Future[T]](failed(new AuthorityNotFound))(t => successful(t))
4950
}
5051
}
5152

app/models/Authority.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package models
1919
import java.util.UUID
2020

2121
import org.joda.time.DateTime
22-
import play.api.libs.json.{Format, JodaReads, JodaWrites, Json, Reads, Writes}
22+
import play.api.libs.json.{Format, JodaReads, JodaWrites, Json}
2323

2424

2525

build.sbt

Lines changed: 19 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,97 +7,49 @@ import uk.gov.hmrc.DefaultBuildSettings._
77
import uk.gov.hmrc.SbtAutoBuildPlugin
88
import uk.gov.hmrc.sbtdistributables.SbtDistributablesPlugin
99
import uk.gov.hmrc.sbtdistributables.SbtDistributablesPlugin._
10-
import uk.gov.hmrc.versioning.SbtGitVersioning
11-
12-
import scala.util.Properties
10+
import bloop.integrations.sbt.BloopDefaults
1311

1412
lazy val appName = "api-revocation-frontend"
1513

16-
lazy val appDependencies: Seq[ModuleID] = compile ++ test
17-
18-
lazy val compile = Seq(
19-
ws,
20-
"uk.gov.hmrc" %% "play-partials" % "6.9.0-play-26",
21-
"uk.gov.hmrc" %% "bootstrap-play-26" % "1.3.0",
22-
"uk.gov.hmrc" %% "play-ui" % "8.12.0-play-26",
23-
"uk.gov.hmrc" %% "govuk-template" % "5.48.0-play-26",
24-
"org.apache.httpcomponents" % "httpclient" % "4.3.3",
25-
"org.apache.httpcomponents" % "httpcore" % "4.3.3",
26-
"com.typesafe.play" %% "play-json-joda" % "2.6.10"
27-
)
28-
29-
lazy val wireMockVersion = "2.21.0"
30-
31-
lazy val test = Seq(
32-
"uk.gov.hmrc" %% "hmrctest" % "3.9.0-play-26" % "test",
33-
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
34-
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % "test",
35-
"com.typesafe.play" %% "play-test" % PlayVersion.current % "test",
36-
"org.pegdown" % "pegdown" % "1.6.0" % "test",
37-
"org.jsoup" % "jsoup" % "1.10.2" % "test",
38-
"com.github.tomakehurst" % "wiremock-jre8" % "2.24.1" % "test",
39-
"org.mockito" % "mockito-core" % "2.13.0" % "test"
40-
)
41-
42-
4314
// Transitive dependencies in scalatest/scalatestplusplay drag in a newer version of jetty that is not
4415
// compatible with wiremock, so we need to pin the jetty stuff to the older version.
4516
// see https://groups.google.com/forum/#!topic/play-framework/HAIM1ukUCnI
46-
val jettyVersion = "9.4.26.v20200117"
4717
lazy val akkaVersion = "2.5.23"
4818
lazy val akkaHttpVersion = "10.0.15"
4919

5020
val overrides: Seq[ModuleID] = Seq(
51-
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
52-
"com.typesafe.akka" %% "akka-protobuf" % akkaVersion,
53-
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
54-
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
55-
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion,
56-
"org.eclipse.jetty" % "jetty-server" % jettyVersion,
57-
"org.eclipse.jetty" % "jetty-servlet" % jettyVersion,
58-
"org.eclipse.jetty" % "jetty-security" % jettyVersion,
59-
"org.eclipse.jetty" % "jetty-servlets" % jettyVersion,
60-
"org.eclipse.jetty" % "jetty-continuation" % jettyVersion,
61-
"org.eclipse.jetty" % "jetty-webapp" % jettyVersion,
62-
"org.eclipse.jetty" % "jetty-xml" % jettyVersion,
63-
"org.eclipse.jetty" % "jetty-client" % jettyVersion,
64-
"org.eclipse.jetty" % "jetty-http" % jettyVersion,
65-
"org.eclipse.jetty" % "jetty-io" % jettyVersion,
66-
"org.eclipse.jetty" % "jetty-util" % jettyVersion,
67-
"org.eclipse.jetty.websocket" % "websocket-api" % jettyVersion,
68-
"org.eclipse.jetty.websocket" % "websocket-common" % jettyVersion,
69-
"org.eclipse.jetty.websocket" % "websocket-client" % jettyVersion
21+
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
22+
"com.typesafe.akka" %% "akka-protobuf" % akkaVersion,
23+
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
24+
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
25+
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion
7026
)
7127

72-
lazy val plugins: Seq[Plugins] = Seq.empty
7328
lazy val playSettings: Seq[Setting[_]] = Seq.empty
7429
lazy val microservice = (project in file("."))
75-
.enablePlugins(Seq(_root_.play.sbt.PlayScala, SbtAutoBuildPlugin, SbtGitVersioning, SbtDistributablesPlugin, SbtArtifactory, SbtWeb) ++ plugins: _*)
30+
.enablePlugins(PlayScala, SbtAutoBuildPlugin, SbtDistributablesPlugin, SbtWeb)
7631
.settings(playSettings: _*)
7732
.settings(scalaSettings: _*)
7833
.settings(publishingSettings: _*)
7934
.settings(defaultSettings(): _*)
35+
.settings(SilencerSettings(): _*)
36+
.settings(ScoverageSettings(): _*)
8037
.settings(
8138
name := appName,
8239
majorVersion := 0,
8340
targetJvm := "jvm-1.8",
84-
scalaVersion := "2.12.10",
85-
libraryDependencies ++= appDependencies,
86-
dependencyOverrides ++= overrides,
87-
parallelExecution in Test := false,
88-
fork in Test := false,
41+
scalaVersion := "2.12.12",
42+
libraryDependencies ++= AppDependencies(),
43+
// dependencyOverrides ++= overrides,
8944
retrieveManaged := true,
9045
evictionWarningOptions in update := EvictionWarningOptions.default.withWarnScalaVersionEviction(false)
9146
)
92-
.settings(testOptions in Test := Seq(Tests.Filter(unitFilter)),
47+
.settings(inConfig(Test)(Defaults.testSettings))
48+
.settings(inConfig(Test)(BloopDefaults.configSettings))
49+
.settings(
50+
Test / fork := false,
51+
Test / parallelExecution := false,
52+
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-eT"),
53+
Test / unmanagedSourceDirectories += baseDirectory.value / "test",
9354
addTestReportOption(Test, "test-reports")
9455
)
95-
96-
97-
def unitFilter(name: String): Boolean = name startsWith "unit"
98-
99-
100-
// Coverage configuration
101-
coverageMinimum := 78
102-
coverageFailOnMinimum := true
103-
coverageExcludedPackages := "<empty>;com.kenshoo.play.metrics.*;.*definition.*;prod.*;testOnlyDoNotUseInAppConf.*;app.*;uk.gov.hmrc.BuildInfo"

project/AppDependencies.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import play.core.PlayVersion
2+
import sbt._
3+
4+
object AppDependencies {
5+
def apply(): Seq[ModuleID] = compile ++ test
6+
7+
lazy val compile = Seq(
8+
"uk.gov.hmrc" %% "play-partials" % "6.9.0-play-26",
9+
"uk.gov.hmrc" %% "bootstrap-play-26" % "4.0.0",
10+
"uk.gov.hmrc" %% "play-ui" % "8.12.0-play-26",
11+
"uk.gov.hmrc" %% "govuk-template" % "5.48.0-play-26",
12+
"org.apache.httpcomponents" % "httpclient" % "4.3.3",
13+
"org.apache.httpcomponents" % "httpcore" % "4.3.3",
14+
"com.typesafe.play" %% "play-json-joda" % "2.6.10"
15+
)
16+
17+
lazy val test = Seq(
18+
"uk.gov.hmrc" %% "hmrctest" % "3.9.0-play-26" % "test",
19+
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
20+
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % "test",
21+
"com.typesafe.play" %% "play-test" % PlayVersion.current % "test",
22+
"org.pegdown" % "pegdown" % "1.6.0" % "test",
23+
"org.jsoup" % "jsoup" % "1.10.2" % "test",
24+
"com.github.tomakehurst" % "wiremock-jre8-standalone" % "2.24.1" % "test",
25+
"org.mockito" %% "mockito-scala-scalatest" % "1.7.1",
26+
)
27+
}

project/ScoverageSettings.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import scoverage.ScoverageKeys._
2+
3+
object ScoverageSettings {
4+
def apply() = Seq(
5+
coverageMinimum := 78,
6+
coverageFailOnMinimum := true,
7+
coverageHighlighting := true,
8+
coverageExcludedPackages := Seq(
9+
"<empty>",
10+
"prod.*",
11+
"testOnlyDoNotUseInAppConf.*",
12+
"app.*",
13+
".*Reverse.*",
14+
".*Routes.*",
15+
"com\\.kenshoo\\.play\\.metrics\\.*",
16+
".*definition.*",
17+
".*BuildInfo.*",
18+
".*javascript"
19+
).mkString(";")
20+
)
21+
}

project/SilencerSettings.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sbt.{CrossVersion, compilerPlugin}
2+
import sbt.Keys._
3+
import sbt._
4+
5+
object SilencerSettings {
6+
// stop "unused import" warnings from routes files
7+
def apply() = Seq(
8+
libraryDependencies ++= Seq(
9+
compilerPlugin("com.github.ghik" % "silencer-plugin" % "1.7.1" cross CrossVersion.full),
10+
"com.github.ghik" % "silencer-lib" % "1.7.1" % Provided cross CrossVersion.full
11+
),
12+
// silence all warnings on autogenerated files
13+
scalacOptions += "-P:silencer:pathFilters=target/.*",
14+
// Make sure you only exclude warnings for the project directories, i.e. make builds reproducible
15+
scalacOptions += s"-P:silencer:sourceRoots=${baseDirectory.value.getCanonicalPath}"
16+
)
17+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.13
1+
sbt.version=1.4.9

project/plugins.sbt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
resolvers += "HMRC-open-artefacts-maven" at "https://open.artefacts.tax.service.gov.uk/maven2"
22
resolvers += Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)
33

4-
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "2.14.0")
5-
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "2.2.0")
4+
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.0.0")
65
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.1.0")
76
addSbtPlugin("org.scoverage" %% "sbt-scoverage" % "1.6.1")
87
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
98
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.24")
10-
addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "1.14.0")
9+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.8")

test/stubs/WireMockHelper.scala

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)