-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4533ae
commit 90f3ca1
Showing
2 changed files
with
112 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...est/java/com/example/restclient/bootrestclient/web/controllers/PostControllerIntTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.restclient.bootrestclient.web.controllers; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
class PostControllerIntTest { | ||
|
||
@Autowired private MockMvc mockMvc; | ||
|
||
@Test | ||
void shouldFindPostById() throws Exception { | ||
|
||
this.mockMvc | ||
.perform(get("/api/posts/{id}", 1)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.id", is(1))) | ||
.andExpect( | ||
jsonPath( | ||
"$.title", | ||
is( | ||
"sunt aut facere repellat provident occaecati excepturi optio reprehenderit"))) | ||
.andExpect(jsonPath("$.userId", is(1))) | ||
.andExpect( | ||
jsonPath( | ||
"$.body", | ||
is( | ||
"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"))); | ||
} | ||
} |