Added test controller

This commit is contained in:
Denis Kazantsev 2022-04-08 20:55:24 +03:00
parent 4eea57c5cf
commit 186990a93e
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package ru.touchin.server.info.controllers
import org.junit.jupiter.api.DisplayName
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.context.ActiveProfiles
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.result.MockMvcResultHandlers
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
class ServerInfoControllerMvcTest {
@Autowired
private lateinit var mockMvc: MockMvc
@Test
fun shouldBeWrappedResponse() {
mockMvc
.perform(MockMvcRequestBuilders.get("/info"))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk)
.andExpect(MockMvcResultMatchers.content().json(
"""
{
"serverInfo": [
{
"X-App-Build-Version": "11"
}
]
}
""".trimIndent()
))
}
}