Skip to content

Commit

Permalink
APIS-7321 - Update to exclude deleted apps from blocked lookup (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias1087 authored Oct 11, 2024
1 parent 5a944a3 commit 6cd6f8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ class ApplicationRepository @Inject() (mongo: MongoComponent, val metrics: Metri
// scalastyle:off cyclomatic.complexity
private def convertFilterToQueryClause(applicationSearchFilter: ApplicationSearchFilter, applicationSearch: ApplicationSearch): Bson = {

def applicationBlocked(): Bson = matches(equal("blocked", BsonBoolean.apply(true)))
def applicationBlocked(): Bson = matches(and(equal("blocked", BsonBoolean.apply(true)), notEqual("state.name", State.DELETED.toString)))

def applicationStatusMatch(states: State*): Bson = in("state.name", states.map(_.toString))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,31 @@ class ApplicationRepositorySearchISpec
}

"return applications based on blocked filter" in {
val standardApplication = anApplicationDataForTest(
val standardApplication = anApplicationDataForTest(
id = ApplicationId.random,
prodClientId = generateClientId
)
val blockedApplication = anApplicationDataForTest(
val blockedApplication = anApplicationDataForTest(
id = ApplicationId.random,
prodClientId = generateClientId
).copy(blocked = true)
val deletedAndBlockedApplication = anApplicationDataForTest(
id = ApplicationId.random,
prodClientId = generateClientId,
state = deletedState("Dave")
).copy(blocked = true)

await(applicationRepository.save(standardApplication))
await(applicationRepository.save(blockedApplication))
await(applicationRepository.save(deletedAndBlockedApplication))

val applicationSearch = new ApplicationSearch(filters = List(Blocked))

val result =
await(applicationRepository.searchApplications("testing")(applicationSearch))

result.totals.size mustBe 1
result.totals.head.total mustBe 2
result.totals.head.total mustBe 3
result.matching.size mustBe 1
result.matching.head.total mustBe 1
result.applications.size mustBe 1
Expand Down

0 comments on commit 6cd6f8e

Please sign in to comment.