From 186990a93e194ffbfdbee17c0c3375d535696759 Mon Sep 17 00:00:00 2001 From: Denis Kazantsev Date: Fri, 8 Apr 2022 20:55:24 +0300 Subject: [PATCH] Added test controller --- .../ServerInfoControllerMvcTest.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 server-info-spring-web/src/test/kotlin/ru/touchin/server/info/controllers/ServerInfoControllerMvcTest.kt diff --git a/server-info-spring-web/src/test/kotlin/ru/touchin/server/info/controllers/ServerInfoControllerMvcTest.kt b/server-info-spring-web/src/test/kotlin/ru/touchin/server/info/controllers/ServerInfoControllerMvcTest.kt new file mode 100644 index 0000000..5956da7 --- /dev/null +++ b/server-info-spring-web/src/test/kotlin/ru/touchin/server/info/controllers/ServerInfoControllerMvcTest.kt @@ -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() + )) + } + +}