-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/#353: DTO Validation test를 Controller test로 수정
- Loading branch information
Showing
4 changed files
with
337 additions
and
294 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
53 changes: 53 additions & 0 deletions
53
BE/exceed/src/test/java/com/gaebaljip/exceed/auth/adapter/in/AuthControllerTest.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,53 @@ | ||
package com.gaebaljip.exceed.auth.adapter.in; | ||
|
||
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.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
|
||
import com.gaebaljip.exceed.auth.adapter.AuthController; | ||
import com.gaebaljip.exceed.auth.application.port.AuthService; | ||
import com.gaebaljip.exceed.common.ControllerTest; | ||
import com.gaebaljip.exceed.common.ValidationMessage; | ||
import com.gaebaljip.exceed.dto.request.LoginRequest; | ||
|
||
@WebMvcTest(AuthController.class) | ||
public class AuthControllerTest extends ControllerTest { | ||
@MockBean private AuthService authService; | ||
|
||
@Test() | ||
@DisplayName("로그인 실패 - 비밀번호 형식 안 맞을 때") | ||
void login_fail() throws Exception { | ||
LoginRequest loginRequest = new LoginRequest("abcd1111!@gmail.com", "abcd"); | ||
|
||
ResultActions resultActions = | ||
mockMvc.perform( | ||
MockMvcRequestBuilders.post("/v1/auth/login") | ||
.content(om.writeValueAsString(loginRequest)) | ||
.contentType(MediaType.APPLICATION_JSON)); | ||
|
||
resultActions.andExpect(status().isBadRequest()); | ||
} | ||
|
||
@Test() | ||
@DisplayName("로그인 실패 - 이메일 형식 안 맞을 때") | ||
void login_fail2() throws Exception { | ||
LoginRequest loginRequest = new LoginRequest("abcd1111gmail.com", "Abc@123"); | ||
|
||
ResultActions resultActions = | ||
mockMvc.perform( | ||
MockMvcRequestBuilders.post("/v1/auth/login") | ||
.content(om.writeValueAsString(loginRequest)) | ||
.contentType(MediaType.APPLICATION_JSON)); | ||
|
||
resultActions.andExpectAll( | ||
status().isBadRequest(), | ||
jsonPath("$.error.reason").value(ValidationMessage.INVALID_EMAIL)); | ||
} | ||
} |
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
Oops, something went wrong.