Skip to content

Commit

Permalink
[FEATURE] E4-S3 회원가입 API - 회원가입 API주소 수정 #25
Browse files Browse the repository at this point in the history
  • Loading branch information
choisungwook committed Oct 8, 2021
1 parent b2d719d commit fe87bc0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class AccountController {
private final AccountService accountService;

@PostMapping("/users")
@PostMapping("/signup")
public ResponseEntity<SignUpResponse> SignUp(@Valid @RequestBody SignupRequestDTO requestDTO) {
log.info("------------------- 회원가입 요청 -----------------------");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.infp.ciat.user.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.infp.ciat.user.controller.dto.request.SignupRequestDTO;
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.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;

import static org.junit.jupiter.api.Assertions.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
class AccountControllerTest {
@Autowired
private MockMvc mockMvc;

@Test
@DisplayName("회원가입")
public void SignUp() throws Exception {
SignupRequestDTO signup_requestdto1 = create_signup_requestdto("test1@test.com", "test1", "password");

mockMvc.perform(
post("/signup")
.contentType(MediaType.APPLICATION_JSON)
.content(new ObjectMapper().writeValueAsString(signup_requestdto1))
)
.andExpect(status().isCreated())
.andDo(print());
}

/***
* 회원가입 요청 DTO 생성
* @param email
* @param nickname
* @param password
* @return
*/
private SignupRequestDTO create_signup_requestdto(String email, String nickname, String password) {
SignupRequestDTO signupRequestDTO = new SignupRequestDTO();
signupRequestDTO.setEmail(email);
signupRequestDTO.setNickname(nickname);
signupRequestDTO.setPassword(password);

return signupRequestDTO;
}
}

0 comments on commit fe87bc0

Please sign in to comment.