Skip to content

Commit

Permalink
Added status check
Browse files Browse the repository at this point in the history
  • Loading branch information
jstsddg committed May 5, 2020
1 parent 3ccc1bd commit 7cb4177
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void testFound() throws Exception {

mockMvc.perform(post("/v2/users/self/favorites/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(true));

Expand Down Expand Up @@ -120,6 +121,7 @@ void testAlreadyFavorite() throws Exception {

mockMvc.perform(post("/v2/users/self/favorites/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(true));

Expand Down Expand Up @@ -155,6 +157,7 @@ void testOccupancy() throws Exception {

mockMvc.perform(post("/v2/users/self/favorites/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(true))
.andExpect(jsonPath("$.occupancy.value").value(occupancy.getOccupancy()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void testFound() throws Exception {

mockMvc.perform(get("/v2/locations/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(false))
.andExpect(jsonPath("$.occupancy.value").doesNotExist())
Expand All @@ -80,6 +81,7 @@ void testFound() throws Exception {

mockMvc.perform(get("/v2/locations/1000"))
// No Authentication
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").doesNotExist())
.andExpect(jsonPath("$.occupancy.value").doesNotExist())
Expand All @@ -105,6 +107,7 @@ void testFoundFavorite() throws Exception {

mockMvc.perform(get("/v2/locations/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(true))
.andExpect(jsonPath("$.occupancy.value").doesNotExist())
Expand All @@ -113,6 +116,7 @@ void testFoundFavorite() throws Exception {

mockMvc.perform(get("/v2/locations/1000"))
// No Authentication
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").doesNotExist())
.andExpect(jsonPath("$.occupancy.value").doesNotExist())
Expand All @@ -138,6 +142,7 @@ void testFoundOccupancy() throws Exception {

mockMvc.perform(get("/v2/locations/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(false))
.andExpect(jsonPath("$.occupancy.value").value(occupancy.getOccupancy()))
Expand All @@ -146,6 +151,7 @@ void testFoundOccupancy() throws Exception {

mockMvc.perform(get("/v2/locations/1000"))
// No Authentication
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").doesNotExist())
.andExpect(jsonPath("$.occupancy.value").value(occupancy.getOccupancy()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ void testEmpty() throws Exception {

mockMvc.perform(get("/v2/locations?latitude=0.0&longitude=0.0")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(0)));

mockMvc.perform(get("/v2/locations?latitude=0.0&longitude=0.0"))
// No Authentication
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(0)));
}

Expand Down Expand Up @@ -132,11 +134,13 @@ void testFound() throws Exception {

mockMvc.perform(get("/v2/locations?latitude=42.0&longitude=7.0")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocationList(locations))
.andExpect(jsonPath("$", hasSize(1)));

mockMvc.perform(get("/v2/locations?latitude=42.0&longitude=7.0"))
// No Authentication
.andExpect(status().isOk())
.andExpect(super.expectLocationList(locations))
.andExpect(jsonPath("$", hasSize(1)));
}
Expand Down Expand Up @@ -168,13 +172,15 @@ void testFavorite() throws Exception {

mockMvc.perform(get("/v2/locations?latitude=42.0&longitude=7.0")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocationList(locations))
.andExpect(jsonPath("$", hasSize(2)))
.andExpect(jsonPath("$.[?(@.id==1000)].favorite").value(true))
.andExpect(jsonPath("$.[?(@.id==2000)].favorite").value(false));

mockMvc.perform(get("/v2/locations?latitude=42.0&longitude=7.0"))
// No Authentication
.andExpect(status().isOk())
.andExpect(super.expectLocationList(locations))
.andExpect(jsonPath("$", hasSize(2)))
// The result is a list and will not automatically unpacked with nullValue()
Expand Down Expand Up @@ -202,6 +208,7 @@ void testOccupancy() throws Exception {
mockMvc.perform(
get("/v2/locations/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(false))
.andExpect(jsonPath("$.occupancy.value").value(occupancy.getOccupancy()))
Expand All @@ -211,6 +218,7 @@ void testOccupancy() throws Exception {
mockMvc.perform(
get("/v2/locations/1000"))
// No Authentication
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").doesNotExist())
.andExpect(jsonPath("$.occupancy.value").value(occupancy.getOccupancy()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void testFound() throws Exception {

mockMvc.perform(get("/v2/users/self/favorites")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocationList(locations))
.andExpect(jsonPath("$", hasSize(2)))
.andExpect(jsonPath("$[*].favorite").value(everyItem(equalTo(true))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void testFavoriteFound() throws Exception {

mockMvc.perform(delete("/v2/users/self/favorites/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(false));

Expand Down Expand Up @@ -166,6 +167,7 @@ void testMultipleFavoritesFound() throws Exception {

mockMvc.perform(delete("/v2/users/self/favorites/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(false));

Expand Down Expand Up @@ -201,6 +203,7 @@ void testOccupancy() throws Exception {

mockMvc.perform(delete("/v2/users/self/favorites/1000")
.header("Authorization", AUTHENTICATION_VALID))
.andExpect(status().isOk())
.andExpect(super.expectLocation(location))
.andExpect(jsonPath("$.favorite").value(false))
.andExpect(jsonPath("$.occupancy.value").value(occupancy.getOccupancy()))
Expand Down

0 comments on commit 7cb4177

Please sign in to comment.