diff --git a/test/uk/gov/hmrc/thirdpartyapplication/models/ApplicationSearchSpec.scala b/test/uk/gov/hmrc/thirdpartyapplication/models/ApplicationSearchSpec.scala index d1f21c01..d9728eca 100644 --- a/test/uk/gov/hmrc/thirdpartyapplication/models/ApplicationSearchSpec.scala +++ b/test/uk/gov/hmrc/thirdpartyapplication/models/ApplicationSearchSpec.scala @@ -20,9 +20,9 @@ import java.time.{ZoneOffset, ZonedDateTime} import play.api.test.FakeRequest +import uk.gov.hmrc.apiplatform.modules.common.domain.models.UserId import uk.gov.hmrc.apiplatform.modules.common.utils.HmrcSpec import uk.gov.hmrc.apiplatform.modules.apis.domain.models.ApiIdentifierSyntax._ -import uk.gov.hmrc.apiplatform.modules.common.domain.models.UserId class ApplicationSearchSpec extends HmrcSpec { @@ -200,7 +200,7 @@ class ApplicationSearchSpec extends HmrcSpec { } "populate user if specific value is provided" in { - val user = UserId.random + val user = UserId.random val request = FakeRequest("GET", s"/applications?user=$user") val searchObject = ApplicationSearch.fromQueryString(request.queryString) diff --git a/test/uk/gov/hmrc/thirdpartyapplication/services/AuditServiceSpec.scala b/test/uk/gov/hmrc/thirdpartyapplication/services/AuditServiceSpec.scala index f31ebdcf..f249a10e 100644 --- a/test/uk/gov/hmrc/thirdpartyapplication/services/AuditServiceSpec.scala +++ b/test/uk/gov/hmrc/thirdpartyapplication/services/AuditServiceSpec.scala @@ -492,6 +492,41 @@ class AuditServiceSpec verify(mockAuditConnector).sendEvent(argThat(isSameDataEvent(expectedDataEvent)))(*, *) } + "applyEvents with a ApplicationDeletedByGatekeeper event" in new Setup { + + val appDeleted = ApplicationEvents.ApplicationDeletedByGatekeeper( + EventId.random, + applicationId, + instant, + Actors.GatekeeperUser(gatekeeperUser), + clientIdOne, + wso2ApplicationName = "wso2", + "reasons", + adminOne.emailAddress + ) + + val expectedDataEvent = DataEvent( + auditSource = "third-party-application", + auditType = ApplicationDeleted.auditType, + tags = hc.toAuditTags(ApplicationDeleted.name, "-") ++ Map("gatekeeperId" -> gatekeeperUser), + detail = Map( + "applicationId" -> applicationId.value.toString, + "applicationAdmins" -> applicationData.admins.map(_.emailAddress).mkString(", "), + "upliftRequestedByEmail" -> applicationData.state.requestedByEmailAddress.getOrElse("-"), + "applicationName" -> applicationData.name.value, + "requestedByEmailAddress" -> adminOne.emailAddress.text + ) + ) + + when(mockAuditConnector.sendEvent(*)(*, *)).thenReturn(Future.successful(AuditResult.Success)) + + val result = await(auditService.applyEvents(applicationData, NonEmptyList.one(appDeleted))) + + result shouldBe Some(AuditResult.Success) + + verify(mockAuditConnector).sendEvent(argThat(isSameDataEvent(expectedDataEvent)))(*, *) + } + "applyEvents with a RedirectUrisUpdated event" in new Setup { val redirectUrisUpdated = ApplicationEvents.RedirectUrisUpdatedV2(