Skip to content

Commit

Permalink
Merge pull request #125 from hmrc/APB-8824
Browse files Browse the repository at this point in the history
APB-8824: Remove StringFallback utility
  • Loading branch information
Artemas-Muzanenhamo authored Oct 11, 2024
2 parents b5a225f + a4d3343 commit 9975778
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 50 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ These endpoints are called during the agent subscription journey.

The "refusal to deal with" and "manually assured" lists are maintained by HMRC helpdesk staff (stride users) in agent-helpdesk-frontend.

## Running the tests

sbt test it/test

## Running the tests with coverage

sbt clean coverageOn test it/test coverageReport

## Run the application locally

sm2 -start AGENT_AUTHORISATION
sm2 -stop AGENT_ASSURANCE

To run the application execute
```
./run.sh
Expand Down
19 changes: 9 additions & 10 deletions app/uk/gov/hmrc/agentassurance/models/AgencyDetails.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import play.api.libs.json.__
import play.api.libs.json.Format
import play.api.libs.json.Json
import play.api.libs.json.OFormat
import uk.gov.hmrc.agentassurance.utils.StringFormatFallbackSetup.stringFormatFallback
import uk.gov.hmrc.crypto.json.JsonEncryption.stringEncrypterDecrypter
import uk.gov.hmrc.crypto.Decrypter
import uk.gov.hmrc.crypto.Encrypter
Expand All @@ -41,9 +40,9 @@ object AgencyDetails {

def agencyDetailsDatabaseFormat(implicit crypto: Encrypter with Decrypter): Format[AgencyDetails] =
(__ \ "agencyName")
.formatNullable[String](stringFormatFallback(stringEncrypterDecrypter))
.and((__ \ "agencyEmail").formatNullable[String](stringFormatFallback(stringEncrypterDecrypter)))
.and((__ \ "agencyTelephone").formatNullable[String](stringFormatFallback(stringEncrypterDecrypter)))
.formatNullable[String](stringEncrypterDecrypter)
.and((__ \ "agencyEmail").formatNullable[String](stringEncrypterDecrypter))
.and((__ \ "agencyTelephone").formatNullable[String](stringEncrypterDecrypter))
.and((__ \ "agencyAddress").formatNullable[BusinessAddress](BusinessAddress.businessAddressDatabaseFormat))(
AgencyDetails.apply,
unlift(AgencyDetails.unapply)
Expand All @@ -64,12 +63,12 @@ object BusinessAddress {

def businessAddressDatabaseFormat(implicit crypto: Encrypter with Decrypter): Format[BusinessAddress] = {
(__ \ "addressLine1")
.format[String](stringFormatFallback(stringEncrypterDecrypter))
.and((__ \ "addressLine2").formatNullable[String](stringFormatFallback(stringEncrypterDecrypter)))
.and((__ \ "addressLine3").formatNullable[String](stringFormatFallback(stringEncrypterDecrypter)))
.and((__ \ "addressLine4").formatNullable[String](stringFormatFallback(stringEncrypterDecrypter)))
.and((__ \ "postalCode").formatNullable[String](stringFormatFallback(stringEncrypterDecrypter)))
.and((__ \ "countryCode").format[String](stringFormatFallback(stringEncrypterDecrypter)))(
.format[String](stringEncrypterDecrypter)
.and((__ \ "addressLine2").formatNullable[String](stringEncrypterDecrypter))
.and((__ \ "addressLine3").formatNullable[String](stringEncrypterDecrypter))
.and((__ \ "addressLine4").formatNullable[String](stringEncrypterDecrypter))
.and((__ \ "postalCode").formatNullable[String](stringEncrypterDecrypter))
.and((__ \ "countryCode").format[String](stringEncrypterDecrypter))(
BusinessAddress.apply,
unlift(BusinessAddress.unapply)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import play.api.libs.json.__
import play.api.libs.json.Format
import play.api.libs.json.Json
import play.api.libs.json.OFormat
import uk.gov.hmrc.agentassurance.utils.StringFormatFallbackSetup.stringFormatFallback
import uk.gov.hmrc.agentmtdidentifiers.model.SuspensionDetails
import uk.gov.hmrc.agentmtdidentifiers.model.Utr
import uk.gov.hmrc.crypto.json.JsonEncryption.stringEncrypterDecrypter
Expand All @@ -42,7 +41,7 @@ object AgentDetailsDesResponse {

def agentRecordDatabaseDetailsFormat(implicit crypto: Encrypter with Decrypter): Format[AgentDetailsDesResponse] =
(__ \ "uniqueTaxReference")
.formatNullable[String](stringFormatFallback(stringEncrypterDecrypter))
.formatNullable[String](stringEncrypterDecrypter)
.bimap[Option[Utr]](
_.map(Utr(_)),
_.map(_.value)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package uk.gov.hmrc.agentassurance.repositories

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

import com.codahale.metrics.MetricRegistry
import org.scalatest.concurrent.Eventually
import org.scalatest.matchers.should.Matchers
Expand Down Expand Up @@ -139,7 +140,7 @@ class AgentDetailsCacheRepositoryISpec
val result = await(agencyDetailsCacheRepository("agent-2")(Future.successful(agencyDetailsResponse)))

result shouldBe agencyDetailsResponse

eventually {
await(agencyDetailsCacheRepository.cacheRepo.collection.find().toFuture()).size shouldBe 1
}
Expand Down

0 comments on commit 9975778

Please sign in to comment.