diff --git a/app/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepository.scala b/app/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepository.scala index c7f6431d8..2993855c6 100644 --- a/app/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepository.scala +++ b/app/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepository.scala @@ -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)) diff --git a/it/test/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepositorySearchISpec.scala b/it/test/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepositorySearchISpec.scala index efa561625..3af5d4c4a 100644 --- a/it/test/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepositorySearchISpec.scala +++ b/it/test/uk/gov/hmrc/thirdpartyapplication/repository/ApplicationRepositorySearchISpec.scala @@ -277,16 +277,23 @@ 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)) @@ -294,7 +301,7 @@ class ApplicationRepositorySearchISpec 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