Skip to content

Commit

Permalink
Merge pull request #1016 from hmrc/DDCYLS-4994
Browse files Browse the repository at this point in the history
Ddcyls 4994
  • Loading branch information
wp94 authored Apr 26, 2024
2 parents 1418d66 + e6e4826 commit 65b68a7
Show file tree
Hide file tree
Showing 217 changed files with 384 additions and 382 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ vat-api has five endpoints:
- GET liabilities

### Prerequisites
- Scala 2.12.x
- Java 8
- sbt > 1.3.7
- Scala 2.13.x
- Java 21
- sbt > 1.9.7
- [Service Manager](https://github.com/hmrc/service-manager)

### Development Setup
Expand All @@ -21,7 +21,7 @@ Run from the console using: `sbt "~run 9675"`
Task | Description | Command
:-------|:------------|:-----
test | Runs the standard unit tests | ```$ sbt test```
func:test | Runs the functional tests | ```$ sbt func:test ```
func:test | Runs the functional tests | ```$ sbt func/test ```
dependencyCheck | Runs dependency-check against the current project. It aggregates dependencies and generates a report | ```$ sbt dependencyCheck```
dependencyUpdates | Shows a list of project dependencies that can be updated | ```$ sbt dependencyUpdates```
dependencyUpdatesReport | Writes a list of project dependencies to a file | ```$ sbt dependencyUpdatesReport```
Expand Down
2 changes: 1 addition & 1 deletion app/config/AppConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
6 changes: 3 additions & 3 deletions app/config/DIModule.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -16,7 +16,7 @@

package config

import akka.actor.{ActorSystem, Scheduler}
import org.apache.pekko.actor.{ActorSystem, Scheduler}
import com.google.inject.{AbstractModule, Provides}

class DIModule extends AbstractModule {
Expand All @@ -26,6 +26,6 @@ class DIModule extends AbstractModule {
}

@Provides
def akkaScheduler(actorSystem: ActorSystem): Scheduler =
def pekkoScheduler(actorSystem: ActorSystem): Scheduler =
actorSystem.scheduler
}
2 changes: 1 addition & 1 deletion app/config/DocumentationController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/FeatureSwitch.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/FeatureToggleSupport.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
4 changes: 2 additions & 2 deletions app/definition/ApiDefinition.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down Expand Up @@ -64,7 +64,7 @@ case class APIDefinition(name: String,
require(uniqueVersions, "version numbers must be unique")

private def uniqueVersions = {
!versions.map(_.version).groupBy(identity).mapValues(_.size).exists(_._2 > 1)
!versions.map(_.version).groupBy(identity).view.mapValues(_.size).toMap.exists(_._2 > 1)
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/definition/ApiDefinitionFactory.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -17,6 +17,7 @@
package definition

import config.AppConfig

import javax.inject.{Inject, Singleton}
import utils.Logging

Expand Down
2 changes: 1 addition & 1 deletion app/definition/Versions.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/routing/VersionRoutingMap.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
5 changes: 3 additions & 2 deletions app/routing/VersionRoutingRequestHandler.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -16,8 +16,9 @@

package routing

import config.{AppConfig, FeatureSwitch, FeatureToggleSupport}
import config.{AppConfig, FeatureToggleSupport}
import definition.Versions

import javax.inject.{Inject, Singleton}
import utils.Logging
import play.api.http.{DefaultHttpRequestHandler, HttpConfiguration, HttpErrorHandler, HttpFilters}
Expand Down
7 changes: 2 additions & 5 deletions app/utils/CurrentDateTime.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -16,17 +16,14 @@

package utils

import java.time.{LocalDateTime, OffsetDateTime}
import java.time.format.DateTimeFormatter

import java.time.OffsetDateTime
import javax.inject.{Inject, Singleton}

@Singleton
class CurrentDateTime @Inject()() {
def getDateTime: OffsetDateTime = OffsetDateTime.now()
def dateString(currentDatetime: OffsetDateTime): OffsetDateTime = {
val formatted = currentDatetime.format(DateUtils.dateTimePattern)
val formatter = DateUtils.dateTimePattern.format(OffsetDateTime.parse(currentDatetime.toString))
OffsetDateTime.parse(formatted)
}
}
2 changes: 1 addition & 1 deletion app/utils/DateUtils.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
6 changes: 3 additions & 3 deletions app/utils/Delayer.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -17,7 +17,7 @@
package utils


import akka.actor.Scheduler
import org.apache.pekko.actor.Scheduler

import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future, Promise}
Expand All @@ -28,7 +28,7 @@ trait Delayer {
implicit val ec: ExecutionContext

def delay(delay: FiniteDuration): Future[Unit] = {
val promise = Promise[Unit]
val promise = Promise[Unit]()

scheduler.scheduleOnce(delay)(promise.success(()))

Expand Down
2 changes: 1 addition & 1 deletion app/utils/EndpointLogContext.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/ErrorHandler.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/FinancialDataReadsUtils.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/HashUtil.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/IdGenerator.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/JsonErrorSanitiser.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
4 changes: 2 additions & 2 deletions app/utils/LegacyErrorHandler.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -20,7 +20,7 @@ import play.api._
import play.api.http.DefaultHttpErrorHandler
import play.api.libs.json.Json
import play.api.mvc.Results.{BadRequest, NotImplemented}
import play.api.mvc.{Request, RequestHeader, Result}
import play.api.mvc.{RequestHeader, Result}
import play.api.routing.Router
import uk.gov.hmrc.http.NotImplementedException
import v1.models.errors._
Expand Down
2 changes: 1 addition & 1 deletion app/utils/Logging.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/NestedJsonReads.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
4 changes: 2 additions & 2 deletions app/utils/Retrying.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -22,7 +22,7 @@ import scala.util.{Failure, Success, Try}
import scala.util.control.NonFatal

object Retrying {
private val fibonacci: Stream[Int] = 1 #:: fibonacci.scanLeft(1)(_ + _)
private val fibonacci: LazyList[Int] = 1 #:: fibonacci.scanLeft(1)(_ + _)

def fibonacciDelays(initialDelay: FiniteDuration, numRetries: Int): List[FiniteDuration] =
fibonacci.take(numRetries).map(i => i * initialDelay).toList
Expand Down
10 changes: 5 additions & 5 deletions app/utils/Timer.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand All @@ -17,7 +17,6 @@
package utils

import com.codahale.metrics._
import com.kenshoo.play.metrics.Metrics
import play.api.mvc.Request

import scala.concurrent.{ExecutionContext, Future}
Expand All @@ -28,7 +27,7 @@ trait Timer {
val defaultTimerGroup: String = "timer"
type Metric = String

val metrics: Metrics
val metrics: MetricRegistry

def timeFuture[A](name: String, metric: Metric, timerGroup: String = defaultTimerGroup)(block: => Future[A])(
implicit ec: ExecutionContext, request: Request[_]): Future[A] = {
Expand All @@ -43,8 +42,9 @@ trait Timer {
finally stopAndLog(name, timer)
}

protected def startTimer(metric: Metric, timerGroup: String): Timer.Context =
metrics.defaultRegistry.timer(s"$metric-$timerGroup").time()
protected def startTimer(metric: Metric, timerGroup: String): Timer.Context = {
metrics.timer(s"$metric-$timerGroup").time()
}

protected def stopAndLog[A](name: String, timer: Timer.Context)(implicit request: Request[_]): Unit = {
val timeMillis = timer.stop() / 1000000
Expand Down
2 changes: 1 addition & 1 deletion app/utils/enums/Enums.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/enums/Values.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/pagerDutyLogging/Endpoint.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/utils/pagerDutyLogging/PagerDutyLogging.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/v1/audit/AuditEvents.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/v1/connectors/BaseDownstreamConnector.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/v1/connectors/DesUri.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/v1/connectors/LiabilitiesConnector.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/v1/connectors/ObligationsConnector.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* 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.
Expand Down
Loading

0 comments on commit 65b68a7

Please sign in to comment.