Skip to content

Commit

Permalink
Merge pull request #1 from hmrc/ADR-749
Browse files Browse the repository at this point in the history
ADR-749 Prepare for development
  • Loading branch information
JemmaEdwards authored Nov 2, 2023
2 parents 6a2cdaa + 1430ac3 commit 8f2bdaf
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 28 deletions.
44 changes: 44 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version = 2.7.1
maxColumn = 120
lineEndings = unix
importSelectors = singleLine

project {
git = true
}

align {
preset = most
tokens = [ {code = "=>", owner = "Case|Type.Arg.ByName"}, "=", "<-", "->", "%", "%%", "should", "shouldBe", "shouldEqual", "shouldNot", "must" ]
arrowEnumeratorGenerator = true
openParenCallSite = false
openParenDefnSite = false
}

binPack {
parentConstructors = false
}

continuationIndent {
callSite = 2
defnSite = 2
}

newlines {
penalizeSingleSelectMultiArgList = false
sometimesBeforeColonInMethodReturnType = true
}

rewrite {
rules = [RedundantBraces, RedundantParens, AsciiSortImports]
redundantBraces {
maxLines = 100
includeUnitMethods = true
stringInterpolation = true
}
}

spaces {
inImportCurlyBraces = false
beforeContextBoundColon = Never
}
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@

# alcohol-duty-returns

This is a placeholder README.md for a new repository
This is the backend microservice that handles Returns related operations for Alcohol Duty Service.

## API Endpoints

## Running the service

> `sbt run`
The service runs on port `16001` by default.

## Running tests

### Unit tests

> `sbt test`
### Integration tests

> `sbt it:test`
## Scalafmt and Scalastyle

To check if all the scala files in the project are formatted correctly:
> `sbt scalafmtCheckAll`
To format all the scala files in the project correctly:
> `sbt scalafmtAll`
To check if there are any scalastyle errors, warnings or infos:
> `sbt scalastyle`
>
> ### All tests and checks
This is an sbt command alias specific to this project. It will run a scala format
check, run a scala style check, run unit tests, run integration tests and produce a coverage report:
> `sbt runAllChecks`
### License

This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").
This code is open source software licensed under
the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").
18 changes: 17 additions & 1 deletion app/uk/gov/hmrc/alcoholdutyreturns/config/AppConfig.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
/*
* Copyright 2023 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.alcoholdutyreturns.config

import javax.inject.{Inject, Singleton}
import play.api.Configuration

@Singleton
class AppConfig @Inject()(config: Configuration) {
class AppConfig @Inject() (config: Configuration) {

val appName: String = config.get[String]("appName")
}
20 changes: 17 additions & 3 deletions app/uk/gov/hmrc/alcoholdutyreturns/config/Module.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
/*
* Copyright 2023 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.alcoholdutyreturns.config

import com.google.inject.AbstractModule

class Module extends AbstractModule {

override def configure(): Unit = {

override def configure(): Unit =
bind(classOf[AppConfig]).asEagerSingleton()
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 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.alcoholdutyreturns.controllers

import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController
Expand All @@ -6,8 +22,7 @@ import javax.inject.{Inject, Singleton}
import scala.concurrent.Future

@Singleton()
class MicroserviceHelloWorldController @Inject()(cc: ControllerComponents)
extends BackendController(cc) {
class MicroserviceHelloWorldController @Inject() (cc: ControllerComponents) extends BackendController(cc) {

def hello(): Action[AnyContent] = Action.async { implicit request =>
Future.successful(Ok("Hello world"))
Expand Down
8 changes: 6 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import uk.gov.hmrc.DefaultBuildSettings.integrationTestSettings
lazy val microservice = Project("alcohol-duty-returns", file("."))
.enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin)
.settings(
majorVersion := 0,
scalaVersion := "2.13.8",
majorVersion := 0,
scalaVersion := "2.13.8",
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",
scalafmtOnCompile := true,
)
.configs(IntegrationTest)
.settings(integrationTestSettings(): _*)
.settings(resolvers += Resolver.jcenterRepo)
.settings(CodeCoverageSettings.settings: _*)
.settings(PlayKeys.playDefaultPort := 16001)

addCommandAlias("runAllChecks", ";clean;compile;scalafmtCheckAll;coverage;test;it:test;scalastyle;coverageReport")
13 changes: 13 additions & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2023 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.

include "backend.conf"

Expand Down
16 changes: 11 additions & 5 deletions conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/alcohol-duty-returns.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n</pattern>
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] message=[%message]
%replace(exception=[%xException]){'^exception=\[\]$',''}%n
</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] rid=[%X{X-Request-ID}] user=[%X{Authorization}] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n</pattern>
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] rid=[%X{X-Request-ID}]
user=[%X{Authorization}] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n
</pattern>
</encoder>
</appender>

<appender name="STDOUT_IGNORE_NETTY" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] rid=[not-available] user=[not-available] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n</pattern>
<pattern>%date{ISO8601} level=[%level] logger=[%logger] thread=[%thread] rid=[not-available]
user=[not-available] message=[%message] %replace(exception=[%xException]){'^exception=\[\]$',''}%n
</pattern>
</encoder>
</appender>

Expand All @@ -36,11 +42,11 @@


<logger name="accesslog" level="INFO" additivity="false">
<appender-ref ref="ACCESS_LOG_FILE" />
<appender-ref ref="ACCESS_LOG_FILE"/>
</logger>

<logger name="com.ning.http.client.providers.netty" additivity="false">
<appender-ref ref="STDOUT_IGNORE_NETTY" />
<appender-ref ref="STDOUT_IGNORE_NETTY"/>
</logger>

<logger name="com.google.inject" level="INFO"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 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.alcoholdutyreturns

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
Expand All @@ -9,11 +25,11 @@ import play.api.inject.guice.GuiceApplicationBuilder
import play.api.libs.ws.WSClient

class HealthEndpointIntegrationSpec
extends AnyWordSpec
with Matchers
with ScalaFutures
with IntegrationPatience
with GuiceOneServerPerSuite {
extends AnyWordSpec
with Matchers
with ScalaFutures
with IntegrationPatience
with GuiceOneServerPerSuite {

private val wsClient = app.injector.instanceOf[WSClient]
private val baseUrl = s"http://localhost:$port"
Expand Down
8 changes: 4 additions & 4 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ object AppDependencies {
private val hmrcMongoVersion = "1.3.0"

val compile = Seq(
"uk.gov.hmrc" %% "bootstrap-backend-play-28" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-28" % hmrcMongoVersion
"uk.gov.hmrc" %% "bootstrap-backend-play-28" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-28" % hmrcMongoVersion
)

val test = Seq(
"uk.gov.hmrc" %% "bootstrap-test-play-28" % bootstrapVersion % "test, it",
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-28" % hmrcMongoVersion % Test,
"uk.gov.hmrc" %% "bootstrap-test-play-28" % bootstrapVersion % "test, it",
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-28" % hmrcMongoVersion % Test
)
}
6 changes: 5 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(
Resolver.ivyStylePatterns
)
resolvers += Resolver.typesafeRepo("releases")

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.14.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.2.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.20")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
2 changes: 1 addition & 1 deletion repository.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
repoVisibility: public_0C3F0CE3E6E6448FAD341E7BFA50FCD333E06A20CFF05FCACE61154DDBBADF71
type: service
service-type: backend
tags: []
tags: [ ]
Loading

0 comments on commit 8f2bdaf

Please sign in to comment.