Skip to content

Commit

Permalink
Merge pull request #141 from jeyrschabu/fix_exception_on_empty_result
Browse files Browse the repository at this point in the history
Fix an unintended 404 on application search of non existent application
  • Loading branch information
anotherchrisberry authored Sep 26, 2016
2 parents 2d67b6f + 53ce8b4 commit 8cb497f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ class CassandraApplicationDAOSpec extends Specification {
foundApplications*.persistedProperties == [newApplication]*.persistedProperties

when:
cassandraApplicationDAO.search([name: newApplicationAttrs.name, group: "does not exist"])
def result = cassandraApplicationDAO.search([name: newApplicationAttrs.name, group: "does not exist"])

then:
thrown(NotFoundException)
result.isEmpty()

when:
foundApplications = cassandraApplicationDAO.search([name: "app"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public interface ApplicationDAO extends ItemDAO<Application> {
return result
} as Set

if (!items) {
throw new NotFoundException("No Application found for search criteria $attributes")
}

return items.sort { Application a, Application b ->
return score(b, attributes) - score(a, attributes)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ class RedisApplicationDAOSpec extends Specification {
foundApplications*.persistedProperties == [newApplication]*.persistedProperties

when:
redisApplicationDAO.search([name: newApplicationAttrs.name, group: "does not exist"])
def result = redisApplicationDAO.search([name: newApplicationAttrs.name, group: "does not exist"])

then:
thrown(NotFoundException)
result.isEmpty()

when:
foundApplications = redisApplicationDAO.search([name: "app"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ abstract class ApplicationsControllerTck extends Specification {
response.andExpect status().isOk()
response.andExpect content().string(new ObjectMapper().writeValueAsString([dao.findByName("SAMPLEAPP")]))

when:
response = mockMvc.perform(
get("/v2/applications?name=non-existent")
)

then:
response.andExpect status().isOk()
notThrown(NotFoundException)
response.andExpect content().string("[]")


when:
response = mockMvc.perform(
get("/v2/applications?name=sample&pageSize=9999")
Expand Down

0 comments on commit 8cb497f

Please sign in to comment.