Skip to content

Commit

Permalink
IMP-COVER - Improve coverage (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias1087 authored Dec 20, 2024
1 parent a566215 commit 443fd7c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 443fd7c

Please sign in to comment.