Skip to content

Instantly share code, notes, and snippets.

@rieckpil
Created July 31, 2023 10:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rieckpil/0b5aaf78d307f05d0c4ce8e62c83edce to your computer and use it in GitHub Desktop.
Save rieckpil/0b5aaf78d307f05d0c4ce8e62c83edce to your computer and use it in GitHub Desktop.
Testing Livetemplates for IntelliJ IDEA
# mockMvcGet
org.springframework.test.web.servlet.MvcResult result = this.mockMvc
.perform(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get($url$)
.header(org.springframework.http.HttpHeaders.ACCEPT, org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status().is(200))
.andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content().contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath("$.size()", org.hamcrest.Matchers.is(0)))
.andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.andReturn();
# mockMvcPost
this.mockMvc
.perform(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post($url$)
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.content("""
{
}
""")
)
.andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status().isCreated());
# test
@org.junit.jupiter.api.Test
void $testName$() throws Exception {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment