From c71555b464d435b9aa5c498ffc0d9108de47edd9 Mon Sep 17 00:00:00 2001 From: sinkyoungdeok Date: Wed, 29 May 2024 02:28:13 +0900 Subject: [PATCH] =?UTF-8?q?[KAN-109]=20=EC=9C=A0=EC=A0=80=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20-=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SignUpUserControllerTest.kt | 89 ++++++++----------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/src/test/kotlin/com/restaurant/be/user/presentation/controller/SignUpUserControllerTest.kt b/src/test/kotlin/com/restaurant/be/user/presentation/controller/SignUpUserControllerTest.kt index fcd32c6..c1a9a34 100644 --- a/src/test/kotlin/com/restaurant/be/user/presentation/controller/SignUpUserControllerTest.kt +++ b/src/test/kotlin/com/restaurant/be/user/presentation/controller/SignUpUserControllerTest.kt @@ -13,18 +13,18 @@ import com.restaurant.be.restaurant.presentation.controller.dto.common.Restauran import com.restaurant.be.user.presentation.dto.SignUpUserResponse import com.restaurant.be.user.repository.UserRepository import io.kotest.matchers.shouldBe +import java.nio.charset.Charset import org.springframework.data.domain.Page import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import org.springframework.transaction.annotation.Transactional -import java.nio.charset.Charset @IntegrationTest @Transactional class SignUpUserControllerTest( - private val mockMvc: MockMvc, - private val userRepository: UserRepository + private val mockMvc: MockMvc, private val userRepository: UserRepository ) : CustomDescribeSpec() { private val baseUrl = "/v1/users" private val objectMapper: ObjectMapper = ObjectMapper().registerModule(KotlinModule()).apply { @@ -48,30 +48,25 @@ class SignUpUserControllerTest( // when val result = mockMvc.perform( - post("$baseUrl/email/sign-up") - .content( - objectMapper.writeValueAsString( - mapOf( - "email" to email, - "password" to password, - "nickname" to nickname, - "profileImageUrl" to profileImageUrl - ) + post("$baseUrl/email/sign-up").content( + objectMapper.writeValueAsString( + mapOf( + "email" to email, + "password" to password, + "nickname" to nickname, + "profileImageUrl" to profileImageUrl ) ) - .contentType("application/json") + ).contentType("application/json") ).also { println(it.andReturn().response.contentAsString) - }.andExpect(status().isOk) - .andExpect(jsonPath("$.result").value("SUCCESS")) + }.andExpect(status().isOk).andExpect(jsonPath("$.result").value("SUCCESS")) .andReturn() val responseContent = result.response.getContentAsString(Charset.forName("UTF-8")) - val responseType = - object : TypeReference>() {} + val responseType = object : TypeReference>() {} val actualResult: CommonResponse = objectMapper.readValue( - responseContent, - responseType + responseContent, responseType ) // then @@ -85,31 +80,25 @@ class SignUpUserControllerTest( // when val result = mockMvc.perform( - post("$baseUrl/email/sign-up") - .content( - objectMapper.writeValueAsString( - mapOf( - "email" to "test@test.com", - "password" to "123456789", - "nickname" to existedUserNickname, - "profileImageUrl" to "" - ) + post("$baseUrl/email/sign-up").content( + objectMapper.writeValueAsString( + mapOf( + "email" to "test@test.com", + "password" to "123456789", + "nickname" to existedUserNickname, + "profileImageUrl" to "" ) ) - .contentType("application/json") + ).contentType("application/json") ).also { println(it.andReturn().response.contentAsString) - } - .andExpect(status().isBadRequest) - .andExpect(jsonPath("$.result").value("FAIL")) + }.andExpect(status().isBadRequest).andExpect(jsonPath("$.result").value("FAIL")) .andReturn() val responseContent = result.response.getContentAsString(Charset.forName("UTF-8")) - val responseType = - object : TypeReference>() {} + val responseType = object : TypeReference>() {} val actualResult: CommonResponse = objectMapper.readValue( - responseContent, - responseType + responseContent, responseType ) // then @@ -122,31 +111,25 @@ class SignUpUserControllerTest( // when val result = mockMvc.perform( - post("$baseUrl/email/sign-up") - .content( - objectMapper.writeValueAsString( - mapOf( - "email" to existedUserEmail, - "password" to "123456789", - "nickname" to "test", - "profileImageUrl" to "" - ) + post("$baseUrl/email/sign-up").content( + objectMapper.writeValueAsString( + mapOf( + "email" to existedUserEmail, + "password" to "123456789", + "nickname" to "test", + "profileImageUrl" to "" ) ) - .contentType("application/json") + ).contentType("application/json") ).also { println(it.andReturn().response.contentAsString) - } - .andExpect(status().isBadRequest) - .andExpect(jsonPath("$.result").value("FAIL")) + }.andExpect(status().isBadRequest).andExpect(jsonPath("$.result").value("FAIL")) .andReturn() val responseContent = result.response.getContentAsString(Charset.forName("UTF-8")) - val responseType = - object : TypeReference>() {} + val responseType = object : TypeReference>() {} val actualResult: CommonResponse = objectMapper.readValue( - responseContent, - responseType + responseContent, responseType ) // then