From a570e113d027f099d428f05cc6ee7ab07b620624 Mon Sep 17 00:00:00 2001 From: seokrae Date: Mon, 18 Oct 2021 13:40:09 +0900 Subject: [PATCH 1/2] feat: settings rest-assured --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index 6df925d..5088cc9 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,10 @@ dependencies { // https://www.archunit.org/getting-started testImplementation 'com.tngtech.archunit:archunit-junit5:0.21.0' + + // https://mvnrepository.com/artifact/io.rest-assured/rest-assured + testImplementation 'io.rest-assured:rest-assured:3.0.0' + } test { From b05a966ed05a44bc3593f644b03f83ad331332c1 Mon Sep 17 00:00:00 2001 From: seokrae Date: Mon, 18 Oct 2021 19:39:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=ED=86=B5=ED=95=A9=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=9D=BC=EB=8A=94=20=EA=B0=9C=EB=85=90?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9D=B8=EC=88=98=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8(rest-assured=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC?= =?UTF-8?q?=EB=A6=AC)=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../articles/dto/RequestUpdateArticle.java | 2 - .../users/dto/RequestLoginUser.java | 12 +- .../users/dto/RequestSaveUser.java | 9 +- .../users/dto/RequestUpdateUser.java | 22 +- .../application/users/persistence/User.java | 3 - .../users/presentation/UserApi.java | 6 - .../users/service/UserBusinessService.java | 2 +- .../realworld/core/config/SecurityConfig.java | 5 +- .../realworld/application/AcceptanceTest.java | 757 ++++++++---------- .../application/users/UserFixture.java | 4 +- .../service/UserBusinessServiceTest.java | 4 +- 12 files changed, 374 insertions(+), 454 deletions(-) diff --git a/build.gradle b/build.gradle index 5088cc9..a0493b3 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,7 @@ dependencies { testImplementation 'com.tngtech.archunit:archunit-junit5:0.21.0' // https://mvnrepository.com/artifact/io.rest-assured/rest-assured - testImplementation 'io.rest-assured:rest-assured:3.0.0' + testImplementation 'io.rest-assured:rest-assured:4.4.0' } diff --git a/src/main/java/com/example/realworld/application/articles/dto/RequestUpdateArticle.java b/src/main/java/com/example/realworld/application/articles/dto/RequestUpdateArticle.java index dc3ade4..82d118a 100644 --- a/src/main/java/com/example/realworld/application/articles/dto/RequestUpdateArticle.java +++ b/src/main/java/com/example/realworld/application/articles/dto/RequestUpdateArticle.java @@ -3,10 +3,8 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.ToString; @Getter -@ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) public class RequestUpdateArticle { diff --git a/src/main/java/com/example/realworld/application/users/dto/RequestLoginUser.java b/src/main/java/com/example/realworld/application/users/dto/RequestLoginUser.java index 1dcddb7..3301042 100644 --- a/src/main/java/com/example/realworld/application/users/dto/RequestLoginUser.java +++ b/src/main/java/com/example/realworld/application/users/dto/RequestLoginUser.java @@ -1,19 +1,21 @@ package com.example.realworld.application.users.dto; -import com.example.realworld.application.users.persistence.User; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import javax.validation.constraints.NotEmpty; @Getter @ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class RequestLoginUser { @NotEmpty(message = "email is not empty") - private final String email; + private String email; @NotEmpty(message = "password is not empty") - private final String password; + private String password; private RequestLoginUser(String email, String password) { this.email = email; @@ -23,8 +25,4 @@ private RequestLoginUser(String email, String password) { public static RequestLoginUser of(String email, String password) { return new RequestLoginUser(email, password); } - - public static User toEntity(RequestLoginUser loginUser) { - return User.of(loginUser.getEmail(), loginUser.getPassword()); - } } diff --git a/src/main/java/com/example/realworld/application/users/dto/RequestSaveUser.java b/src/main/java/com/example/realworld/application/users/dto/RequestSaveUser.java index b577143..10fc528 100644 --- a/src/main/java/com/example/realworld/application/users/dto/RequestSaveUser.java +++ b/src/main/java/com/example/realworld/application/users/dto/RequestSaveUser.java @@ -1,7 +1,9 @@ package com.example.realworld.application.users.dto; import com.example.realworld.application.users.persistence.User; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import org.springframework.security.crypto.password.PasswordEncoder; @@ -9,14 +11,15 @@ @Getter @ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class RequestSaveUser { @NotEmpty(message = "email is not empty") - private final String email; + private String email; @NotEmpty(message = "userName is not empty") - private final String userName; + private String userName; @NotEmpty(message = "password is not empty") - private final String password; + private String password; private RequestSaveUser(String email, String userName, String password) { this.email = email; diff --git a/src/main/java/com/example/realworld/application/users/dto/RequestUpdateUser.java b/src/main/java/com/example/realworld/application/users/dto/RequestUpdateUser.java index 1a562f8..b0aa590 100644 --- a/src/main/java/com/example/realworld/application/users/dto/RequestUpdateUser.java +++ b/src/main/java/com/example/realworld/application/users/dto/RequestUpdateUser.java @@ -1,30 +1,28 @@ package com.example.realworld.application.users.dto; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; -import javax.validation.constraints.NotEmpty; - @Getter @ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class RequestUpdateUser { - @NotEmpty(message = "email is not empty") - private final String email; - private final String userName; - private final String password; - private final String image; - private final String bio; + private String userName; + private String password; + private String image; + private String bio; - private RequestUpdateUser(String email, String userName, String password, String image, String bio) { - this.email = email; + private RequestUpdateUser(String userName, String password, String image, String bio) { this.userName = userName; this.password = password; this.image = image; this.bio = bio; } - public static RequestUpdateUser of(String email, String userName, String password, String image, String bio) { - return new RequestUpdateUser(email, userName, password, image, bio); + public static RequestUpdateUser of(String userName, String password, String image, String bio) { + return new RequestUpdateUser(userName, password, image, bio); } } diff --git a/src/main/java/com/example/realworld/application/users/persistence/User.java b/src/main/java/com/example/realworld/application/users/persistence/User.java index 661c478..4813fd2 100644 --- a/src/main/java/com/example/realworld/application/users/persistence/User.java +++ b/src/main/java/com/example/realworld/application/users/persistence/User.java @@ -88,9 +88,6 @@ public User generateToken(String generateToken) { // 프로필 업데이트 public void update(RequestUpdateUser updateUser) { - if (StringUtils.hasText(updateUser.getEmail())) { - this.email = updateUser.getEmail(); - } if (StringUtils.hasText(updateUser.getPassword())) { this.password = updateUser.getPassword(); } diff --git a/src/main/java/com/example/realworld/application/users/presentation/UserApi.java b/src/main/java/com/example/realworld/application/users/presentation/UserApi.java index 950ae4b..f634572 100644 --- a/src/main/java/com/example/realworld/application/users/presentation/UserApi.java +++ b/src/main/java/com/example/realworld/application/users/presentation/UserApi.java @@ -2,7 +2,6 @@ import com.example.realworld.application.users.dto.RequestUpdateUser; import com.example.realworld.application.users.dto.ResponseUser; -import com.example.realworld.application.users.exception.UnauthorizedUserException; import com.example.realworld.application.users.service.UserService; import com.example.realworld.core.security.context.UserDetailsContext; import lombok.RequiredArgsConstructor; @@ -49,11 +48,6 @@ public ResponseEntity putUser( @Valid @RequestBody RequestUpdateUser updateUser) { String email = userDetailsContext.getUsername(); - // 일단 이메일 정보가 일치해야 수정이 가능한 것으로 간주. - if (!email.equals(updateUser.getEmail())) { - throw new UnauthorizedUserException(); - } - ResponseUser responseUser = userService.updateUser(email, updateUser); return ResponseEntity.status(HttpStatus.OK).body(responseUser); diff --git a/src/main/java/com/example/realworld/application/users/service/UserBusinessService.java b/src/main/java/com/example/realworld/application/users/service/UserBusinessService.java index 63c4ece..a61fce6 100644 --- a/src/main/java/com/example/realworld/application/users/service/UserBusinessService.java +++ b/src/main/java/com/example/realworld/application/users/service/UserBusinessService.java @@ -72,7 +72,7 @@ public ResponseUser getUserByEmail(String email) { /** * 현재 사용자의 프로필 정보 조회 * - * @param email 현재 사용자의 이메일 정보 + * @param toEmail 현재 사용자의 이메일 정보 * @return 현재 사용자의 프로필 정보 반환 */ @Override diff --git a/src/main/java/com/example/realworld/core/config/SecurityConfig.java b/src/main/java/com/example/realworld/core/config/SecurityConfig.java index 6260e18..d47c60e 100644 --- a/src/main/java/com/example/realworld/core/config/SecurityConfig.java +++ b/src/main/java/com/example/realworld/core/config/SecurityConfig.java @@ -74,7 +74,10 @@ protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers(POST, "/api/users/login", "/api/users").permitAll() - .antMatchers(GET, "/api/tags", "/api/articles", "/api/articles/feed", "/api/profiles/*").permitAll() + .antMatchers(GET, + "/api/tags", "/api/articles", "/api/articles/*", + "/api/articles/feed", "/api/profiles/*", "/api/articles/*/comments" + ).permitAll() .anyRequest().authenticated() .and() .addFilter(jwtAuthenticationFilter()) diff --git a/src/test/java/com/example/realworld/application/AcceptanceTest.java b/src/test/java/com/example/realworld/application/AcceptanceTest.java index d20ca22..4e5bc72 100644 --- a/src/test/java/com/example/realworld/application/AcceptanceTest.java +++ b/src/test/java/com/example/realworld/application/AcceptanceTest.java @@ -7,549 +7,478 @@ import com.example.realworld.application.users.dto.RequestLoginUser; import com.example.realworld.application.users.dto.RequestSaveUser; import com.example.realworld.application.users.dto.RequestUpdateUser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import io.restassured.RestAssured; +import io.restassured.config.ObjectMapperConfig; +import io.restassured.config.RestAssuredConfig; +import io.restassured.response.Response; import org.junit.jupiter.api.*; 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.boot.web.server.LocalServerPort; import org.springframework.data.domain.PageRequest; -import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.test.web.servlet.MockMvc; - -import java.util.Objects; import static com.example.realworld.application.articles.ArticleFixture.*; import static com.example.realworld.application.users.UserFixture.*; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.springframework.http.HttpHeaders.AUTHORIZATION; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest -@AutoConfigureMockMvc +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestInstance(PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class AcceptanceTest { private static final String BEARER_PREFIX = "Bearer "; - private static final String REPLACEMENT_EMPTY_DELIMITER = ""; - private String sr_token; - private String seok_token; - private Long commentId; + private String user1Token; + private String user2Token; @Autowired - protected MockMvc mockMvc; - @Autowired - protected ObjectMapper mapper; + private ObjectMapper mapper; + + @LocalServerPort + private int port; + private long commentId; + + @BeforeEach + void setUp() { + RestAssured.port = port; + //serialize, deserialize + RestAssured.config = RestAssuredConfig.config() + .objectMapperConfig( + new ObjectMapperConfig().jackson2ObjectMapperFactory((cls, charset) -> { + ObjectMapper mapper = new ObjectMapper().findAndRegisterModules(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); + return mapper; + }) + ); + } @Order(1) - @DisplayName("사용자(SeokRae) 등록 테스트") + @DisplayName("사용자(user1) 등록 테스트") @Test - void when_signUpUser_expect_success_new_user() throws Exception { - // given - RequestSaveUser requestSaveUser = getRequestSaveUser("seokrae@gmail.com"); - // then - mockMvc.perform( - post("/api/users") - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(requestSaveUser)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isCreated()) - .andExpect(jsonPath("email").value("seokrae@gmail.com")) - .andExpect(jsonPath("userName").value("seokrae")); + void when_signUp_user1() throws JsonProcessingException { + RequestSaveUser requestSaveUser = getRequestSaveUser("user1@gmail.com", "user1"); + given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(requestSaveUser)) // jackson object mapper 가 꼭 필요한가? + .when() + .post("/api/users") + .then() + .assertThat().statusCode(HttpStatus.CREATED.value()); } @Order(2) - @DisplayName("사용자(Seok) 등록 테스트") + @DisplayName("사용자(user2) 등록 테스트") @Test - void when_signUpUser_expect_success_other_user() throws Exception { - // given - RequestSaveUser requestSaveUser = getRequestSaveUser("seok@gmail.com", "seok"); - // then - mockMvc.perform( - post("/api/users") - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(requestSaveUser)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isCreated()) - .andExpect(jsonPath("email").value("seok@gmail.com")) - .andExpect(jsonPath("userName").value("seok")); + void when_signUp_user2() throws JsonProcessingException { + RequestSaveUser requestSaveUser = getRequestSaveUser("user2@gmail.com", "user2"); + given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(requestSaveUser)) // jackson object mapper 가 꼭 필요한가? + .when() + .post("/api/users") + .then() + .assertThat().statusCode(HttpStatus.CREATED.value()); } @Order(3) - @DisplayName("사용자(SeokRae) 로그인 API 테스트") + @DisplayName("사용자(user1) 로그인 테스트") @Test - void when_loginUser_expect_success_return_token() throws Exception { - // given - String email = "seokrae@gmail.com"; - RequestLoginUser loginUser = getRequestLoginUser(email); - // when - - // then₩ - MockHttpServletResponse response = mockMvc.perform( - post("/api/users/login") - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(loginUser)) - ) - .andExpect(status().isOk()) - .andReturn().getResponse(); - - String header = response.getHeader(HttpHeaders.AUTHORIZATION); - sr_token = Objects.requireNonNull(header).replace(BEARER_PREFIX, REPLACEMENT_EMPTY_DELIMITER); + void when_login_user1() throws JsonProcessingException { + RequestLoginUser requestLoginUser = getRequestLoginUser("user1@gmail.com"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(requestLoginUser)) + .when() + .post("/api/users/login") + .andReturn(); + + response + .then() + .assertThat().statusCode(HttpStatus.OK.value()); + user1Token = response.header(AUTHORIZATION); } @Order(4) - @DisplayName("사용자(Seok) 로그인 API 테스트") + @DisplayName("사용자(user2) 로그인 테스트") @Test - void when_loginUser_expect_success_other_user() throws Exception { - String email = "seok@gmail.com"; - RequestLoginUser loginUser = getRequestLoginUser(email); - MockHttpServletResponse response = mockMvc.perform( - post("/api/users/login") - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(loginUser)) - ) - .andExpect(status().isOk()) - .andReturn().getResponse(); - - String header = response.getHeader(HttpHeaders.AUTHORIZATION); - seok_token = Objects.requireNonNull(header).replace(BEARER_PREFIX, REPLACEMENT_EMPTY_DELIMITER); + void when_login_user2() throws JsonProcessingException { + RequestLoginUser requestLoginUser = getRequestLoginUser("user2@gmail.com"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(requestLoginUser)) + .when() + .post("/api/users/login") + .andReturn(); + + response + .then() + .assertThat().statusCode(HttpStatus.OK.value()); + user2Token = response.header(AUTHORIZATION); } @Order(5) - @DisplayName("프로필 조회 테스트") + @DisplayName("특정 사용자(user1) 프로필 조회 테스트") @Test - void when_getProfile_expect() throws Exception { - // given - String currentUserEmail = "seokrae@gmail.com"; - // when - // then - mockMvc.perform( - get("/api/profiles/{toEmail}", currentUserEmail) - .header(HttpHeaders.AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("email").value("seokrae@gmail.com")) - .andExpect(jsonPath("userName").value("seokrae")); + void when_getProfile_expect_success_user1() { + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .get("/api/profiles/{toEmail}", "user1@gmail.com"); + + response + .then() + .assertThat().statusCode(HttpStatus.OK.value()) + .body("email", is("user1@gmail.com")) + .body("userName", is("user1")); } @Order(6) - @DisplayName("프로필 조회 (JWT 없이 요청) 테스트") + @DisplayName("특정 사용자 프로필 조회 (JWT 없이 조회) 테스트") @Test - void when_getProfile_expect_success() throws Exception { - // given - String currentUserEmail = "seokrae@gmail.com"; - // when - // then - mockMvc.perform( - get("/api/profiles/{toEmail}", currentUserEmail) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.email").value("seokrae@gmail.com")) - .andExpect(jsonPath("$.userName").value("seokrae")) - .andExpect(jsonPath("$.following").value(false)); + void when_getProfile_fail_jwt_exception() { + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when() + .get("/api/profiles/{toEmail}", "user2@gmail.com"); + + response + .then() + .assertThat().statusCode(HttpStatus.OK.value()) + .body("email", is("user2@gmail.com")) + .body("userName", is("user2")); } @Order(7) - @DisplayName("프로필 조회 (현재 사용자 존재 시) 테스트") + @DisplayName("사용자(user1) 조회 테스트") @Test - void when_getProfile_expect_success_auth() throws Exception { - mockMvc.perform( - get("/api/profiles/{toEmail}", "seok@gmail.com") - .header(HttpHeaders.AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("email").value("seok@gmail.com")) - .andExpect(jsonPath("userName").value("seok")) - .andExpect(jsonPath("following").value(false)); + void when_currentUser() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .get("/api/user"); + + response + .then() + .assertThat().statusCode(HttpStatus.OK.value()) + .body("email", is("user1@gmail.com")) + .body("userName", is("user1")); } @Order(8) - @DisplayName("현재 사용자의 정보를 조회") + @DisplayName("사용자 조회 권한 (예외) 테스트") @Test - void when_getCurrentUser_expect_success_get_current_user() throws Exception { - mockMvc.perform( - get("/api/user") - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("email").value("seokrae@gmail.com")) - .andExpect(jsonPath("userName").value("seokrae")); + void when_currentUser_fail_unAuthorization() { + Response response = given() + .when() + .get("/api/user"); + + response.then() + .assertThat().statusCode(HttpStatus.UNAUTHORIZED.value()); } @Order(9) - @DisplayName("현재 사용자의 정보를 조회 실패 (JWT 없이 요청) 테스트") + @DisplayName("사용자(user1)의 정보 수정 테스트") @Test - void when_getCurrentUser_expect_fail_session_is_empty() throws Exception { - mockMvc.perform( - get("/api/user") - ) - .andExpect(status().isUnauthorized()); + void when_putUser_expect_success_user1_change_info() throws JsonProcessingException { + RequestUpdateUser updateUser = getRequestUpdateUser("updatedUser", "1234", "newImage.png", "newBio"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .body(mapper.writeValueAsString(updateUser)) + .when() + .put("/api/user"); + + response.then() + .assertThat().statusCode(HttpStatus.OK.value()); } @Order(10) - @DisplayName("현재 사용자의 정보를 수정") + @DisplayName("사용자의 정보를 수정 (JWT 인가 예외) 테스트") @Test - void when_putUser_expect_success_updated_user_info() throws Exception { - RequestUpdateUser updateUser = getRequestUpdateUser("seokrae@gmail.com", "updatedUser", "1234", "newImage.png", "newBio"); - mockMvc.perform( - put("/api/user") - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(updateUser)) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("email").value("seokrae@gmail.com")) - .andExpect(jsonPath("userName").value("updatedUser")) - .andExpect(jsonPath("bio").value("newBio")) - .andExpect(jsonPath("image").value("newImage.png")); + void when_putUser_expect_fail_unAuthorization() throws JsonProcessingException { + RequestUpdateUser updateUser = getRequestUpdateUser("updatedUser", "1234", "newImage.png", "newBio"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(updateUser)) + .when() + .put("/api/user"); + + response.then() + .assertThat().statusCode(HttpStatus.UNAUTHORIZED.value()); } @Order(11) - @DisplayName("현재 사용자의 정보를 수정 (빈 이메일 권한예외) 테스트") + @DisplayName("팔로우(user1 -> user2) 성공 시 프로필 조회 테스트") @Test - void when_putUser_expect_fail_unAuthorized() throws Exception { - RequestUpdateUser updateUser = getRequestUpdateUser("seokrae@gmail.com", "updatedUser", "1234", "newImage.png", "newBio"); - mockMvc.perform( - put("/api/user") - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(updateUser)) - ) - .andExpect(status().isUnauthorized()); + void when_followUser_expect_success() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .post("/api/profiles/{toEmail}/follow", "user2@gmail.com"); + response.then() + .assertThat().statusCode(HttpStatus.OK.value()) + .body("email", is("user2@gmail.com")) + .body("userName", is("user2")) + .body("following", is(true)); } @Order(12) - @DisplayName("현재 사용자의 정보를 수정 (잘못된 이메일로 권한예외) 테스트") + @DisplayName("팔로우(user1 -> user2) 실패 예외 (권한 예외) 테스트") @Test - void when_putUser_expect_fail_un_matches_email_unAuthorized() throws Exception { - RequestUpdateUser updateUser = getRequestUpdateUser("seokrae@gmail.com", "updatedUser", "1234", "newImage.png", "newBio"); - mockMvc.perform( - put("/api/user") - .header(AUTHORIZATION, BEARER_PREFIX + seok_token) - .contentType(MediaType.APPLICATION_JSON) - .content(mapper.writeValueAsString(updateUser)) - ) - .andExpect(status().isUnauthorized()); + void when_followUser_expect_fail_unAuthorization() { + Response response = given() + .when() + .post("/api/profiles/{toEmail}/follow", "user2@gmail.com"); + response.then() + .assertThat().statusCode(HttpStatus.UNAUTHORIZED.value()); } @Order(13) - @DisplayName("팔로우 성공 시 프로필 조회 테스트") + @DisplayName("사용자(user1)의 글 등록1 작성 테스트") @Test - void when_postFollowUser_expect_success() throws Exception { - // given - // when - // then - mockMvc.perform( - post("/api/profiles/{toEmail}/follow", "seok@gmail.com") - .header(HttpHeaders.AUTHORIZATION, BEARER_PREFIX + sr_token) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("email").value("seok@gmail.com")) - .andExpect(jsonPath("userName").value("seok")) - .andExpect(jsonPath("following").value(true)); + void when_post_by_seokRae_expect_success_article1() throws JsonProcessingException { + RequestSaveArticle requestSaveArticle = getRequestSaveArticle(1, "Java", "JavaScript"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .body(mapper.writeValueAsString(requestSaveArticle)) + .when() + .post("/api/articles"); + + response.then() + .assertThat().statusCode(HttpStatus.CREATED.value()); } @Order(14) - @DisplayName("팔로우 성공 시 프로필 조회 (권한 예외) 실패 테스트") + @DisplayName("사용자(user2)의 글 등록2 작성 테스트") @Test - void when_postFollowUser_expect_fail_unAuthorize_exception() throws Exception { - // given - // when - // then - mockMvc.perform( - post("/api/profiles/{toEmail}/follow", "seok@gmail.com") - ) - .andExpect(status().isUnauthorized()); + void when_post_by_seokRae_expect_success_article2() throws JsonProcessingException { + RequestSaveArticle requestSaveArticle = getRequestSaveArticle(2, "Java", "JavaScript"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .header(AUTHORIZATION, BEARER_PREFIX + user2Token) + .body(mapper.writeValueAsString(requestSaveArticle)) + .when() + .post("/api/articles"); + + response.then() + .assertThat().statusCode(HttpStatus.CREATED.value()); } @Order(15) - @DisplayName("사용자(SeokRae)의 글 작성 테스트") + @DisplayName("사용자(user2)의 글 등록3 작성 테스트") @Test - void when_postArticle_expect_success_new_article() throws Exception { - RequestSaveArticle requestSaveArticle = getRequestSaveArticle(1, "Java", "JavaScript"); - mockMvc.perform( - post("/api/articles") - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .content(mapper.writeValueAsString(requestSaveArticle)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isCreated()) - .andExpect(jsonPath("$.slug").value(makeSlug("타이틀-1"))) - .andExpect(jsonPath("$.title").value("타이틀-1")) - .andExpect(jsonPath("$.description").value("설명")) - .andExpect(jsonPath("$.body").value("내용")) - .andExpect(jsonPath("$.tagList.[0]").value("Java")) - .andExpect(jsonPath("$.tagList.[1]").value("JavaScript")) - .andExpect(jsonPath("$.favorited").value(false)) - .andExpect(jsonPath("$.favoritesCount").value(0)) - .andExpect(jsonPath("$.author.email").value("seokrae@gmail.com")) - .andExpect(jsonPath("$.author.userName").value("updatedUser")) - .andExpect(jsonPath("$.author.following").value(false)); + void when_post_by_seok_expect_success_article1() throws JsonProcessingException { + RequestSaveArticle requestSaveArticle = getRequestSaveArticle(3, "Java", "JavaScript"); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .header(AUTHORIZATION, BEARER_PREFIX + user2Token) + .body(mapper.writeValueAsString(requestSaveArticle)) + .when() + .post("/api/articles"); + + response.then() + .assertThat().statusCode(HttpStatus.CREATED.value()); } @Order(16) - @DisplayName("사용자(seok)의 글 작성 테스트") + @DisplayName("특정 글 조회 테스트") @Test - void when_postArticle_expect_success_new_article2() throws Exception { - RequestSaveArticle requestSaveArticle = getRequestSaveArticle(2, "Java", "Spring"); - mockMvc.perform( - post("/api/articles") - .header(AUTHORIZATION, BEARER_PREFIX + seok_token) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .content(mapper.writeValueAsString(requestSaveArticle)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isCreated()) - .andExpect(jsonPath("$.slug").value(makeSlug("타이틀-2"))) - .andExpect(jsonPath("$.title").value("타이틀-2")) - .andExpect(jsonPath("$.description").value("설명")) - .andExpect(jsonPath("$.body").value("내용")) - .andExpect(jsonPath("$.tagList.[0]").value("Java")) - .andExpect(jsonPath("$.tagList.[1]").value("Spring")) - .andExpect(jsonPath("$.favorited").value(false)) - .andExpect(jsonPath("$.favoritesCount").value(0)) - .andExpect(jsonPath("$.author.email").value("seok@gmail.com")) - .andExpect(jsonPath("$.author.userName").value("seok")) - .andExpect(jsonPath("$.author.following").value(true)); + void when_getArticle_expect_success_article() { + Response response = given() + .when() + .get("/api/articles/{slug}", makeSlug("타이틀-2")); + + response.then() + .assertThat().statusCode(HttpStatus.OK.value()); } @Order(17) - @DisplayName("특정 글 조회 테스트") + @DisplayName("글 페이징 조건 조회 테스트") @Test - void when_getArticle_expect_success_article() throws Exception { - mockMvc.perform( - get("/api/articles/{slug}", makeSlug("타이틀-1")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.slug").value(makeSlug("타이틀-1"))) - .andExpect(jsonPath("$.title").value("타이틀-1")) - .andExpect(jsonPath("$.description").value("설명")) - .andExpect(jsonPath("$.body").value("내용")) - .andExpect(jsonPath("$.tagList.[0]").value("Java")) - .andExpect(jsonPath("$.favorited").value(false)) - .andExpect(jsonPath("$.favoritesCount").value(0)) - .andExpect(jsonPath("$.author.email").value("seokrae@gmail.com")) - .andExpect(jsonPath("$.author.userName").value("updatedUser")) - .andExpect(jsonPath("$.author.following").value(false)); + void when_getArticles_expect_success_page_article() { + RequestArticleCondition pageCondition = + RequestArticleCondition.of("JavaScript", null, null); + + Response response = given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(pageCondition) + .when() + .get("/api/articles"); + + response + .then().assertThat().statusCode(HttpStatus.OK.value()); } @Order(18) - @DisplayName("글 페이징 조건 조회") + @DisplayName("피드 조회 테스트") @Test - void when_getArticles_expect_success_page_article() throws Exception { - RequestArticleCondition pageCondition = - RequestArticleCondition.of("Java", null, null); - mockMvc.perform( - get("/api/articles") - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .content(mapper.writeValueAsString(pageCondition)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andDo(print()) - .andExpect(status().isOk()); + void when_getFeed_expect_success_following_article() { + PageRequest pageRequest = PageRequest.of(0, 20); + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .body(pageRequest) + .when() + .get("/api/articles/feed"); + + response + .then().assertThat().statusCode(HttpStatus.OK.value()); } @Order(19) - @DisplayName("피드 조회 테스트") + @DisplayName("언팔로우 프로필 조회 테스트") @Test - void when_getPeed_expect_success_following_article() throws Exception { - // user given - PageRequest pageRequest = PageRequest.of(0, 20); - // then - mockMvc.perform( - get("/api/articles/feed") - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .content(mapper.writeValueAsString(pageRequest)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andDo(print()) - .andExpect(status().isOk()); + void when_unFollowUser_expect_success() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .delete("/api/profiles/{toEmail}/follow", "user2@gmail.com"); + + response + .then().assertThat().statusCode(HttpStatus.OK.value()); } @Order(20) - @DisplayName("언팔로우 시 프로필 조회 테스트") + @DisplayName("사용자의 관심 글 등록 테스트") @Test - void when_deleteUnFollowUser_expect_success() throws Exception { - // given - String toUserEmail = "seok@gmail.com"; - // when - // then - mockMvc.perform( - delete("/api/profiles/{toEmail}/follow", toUserEmail) - .header(HttpHeaders.AUTHORIZATION, BEARER_PREFIX + sr_token) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("email").value(toUserEmail)) - .andExpect(jsonPath("userName").value("seok")) - .andExpect(jsonPath("following").value(false)); + void when_favoriteArticle_expect_success_favorite() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .post("/api/articles/{slug}/favorite", makeSlug("타이틀-2")); + + response + .then().assertThat().statusCode(HttpStatus.OK.value()); } @Order(21) - @DisplayName("관심 글 등록 테스트") + @DisplayName("사용자의 관심 글 취소 테스트") @Test - void when_favoriteArticle_expect_success_favorite() throws Exception { - mockMvc.perform( - post("/api/articles/{slug}/favorite", makeSlug("타이틀-2")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.slug").value(makeSlug("타이틀-2"))) - .andExpect(jsonPath("$.title").value("타이틀-2")) - .andExpect(jsonPath("$.description").value("설명")) - .andExpect(jsonPath("$.body").value("내용")) - .andExpect(jsonPath("$.tagList.[0]").value("Java")) - .andExpect(jsonPath("$.tagList.[1]").value("Spring")) - .andExpect(jsonPath("$.favorited").value(true)) - .andExpect(jsonPath("$.favoritesCount").value(1)) - .andExpect(jsonPath("$.author.email").value("seok@gmail.com")) - .andExpect(jsonPath("$.author.userName").value("seok")) - .andExpect(jsonPath("$.author.following").value(false)); + void when_unFavoriteArticle_expect_success_un_favorite() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .delete("/api/articles/{slug}/favorite", makeSlug("타이틀-2")); + + response + .then().assertThat().statusCode(HttpStatus.OK.value()); } @Order(22) - @DisplayName("관심 글 취소") + @DisplayName("특정 글 수정 테스트") @Test - void when_unFavoriteArticle_expect_success_un_favorite() throws Exception { - mockMvc.perform( - delete("/api/articles/{slug}/favorite", makeSlug("타이틀-2")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.slug").value(makeSlug("타이틀-2"))) - .andExpect(jsonPath("$.title").value("타이틀-2")) - .andExpect(jsonPath("$.description").value("설명")) - .andExpect(jsonPath("$.body").value("내용")) - .andExpect(jsonPath("$.tagList.[0]").value("Java")) - .andExpect(jsonPath("$.tagList.[1]").value("Spring")) - .andExpect(jsonPath("$.favorited").value(false)) - .andExpect(jsonPath("$.favoritesCount").value(0)) - .andExpect(jsonPath("$.author.email").value("seok@gmail.com")) - .andExpect(jsonPath("$.author.userName").value("seok")) - .andExpect(jsonPath("$.author.following").value(false)); + void when_updateArticle_expect_success_updated_article() throws JsonProcessingException { + RequestUpdateArticle updateArticle = getRequestUpdateArticle("수정된 타이틀", "설명 추가", "내용"); + + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user2Token) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(updateArticle)) + .when() + .put("/api/articles/{slug}", makeSlug("타이틀-2")); + + response + .then().assertThat().statusCode(HttpStatus.OK.value()) + .body("slug", is(makeSlug("수정된 타이틀"))) + .body("author.email", is("user2@gmail.com")); } @Order(23) - @DisplayName("특정 글 수정 테스트") + @DisplayName("특정(본인) 글에 커멘트 등록 하는 테스트") @Test - void when_updateArticle_expect_success_updated_article() throws Exception { - RequestUpdateArticle updateArticle = getRequestUpdateArticle("수정된 타이틀", "설명 추가", "내용"); - mockMvc.perform( - put("/api/articles/{slug}", makeSlug("타이틀-1")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .content(mapper.writeValueAsString(updateArticle)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.slug").value(makeSlug("수정된 타이틀"))) - .andExpect(jsonPath("$.title").value("수정된 타이틀")) - .andExpect(jsonPath("$.description").value("설명 추가")) - .andExpect(jsonPath("$.body").value("내용")) - .andExpect(jsonPath("$.tagList.[0]").value("Java")) - .andExpect(jsonPath("$.favorited").value(false)) - .andExpect(jsonPath("$.favoritesCount").value(0)) - .andExpect(jsonPath("$.author.email").value("seokrae@gmail.com")) - .andExpect(jsonPath("$.author.userName").value("updatedUser")) - .andExpect(jsonPath("$.author.following").value(false)); + void when_post_comment_expect_success() throws JsonProcessingException { + RequestSaveComment requestSaveComment = RequestSaveComment.from("글 좋아요 ~"); + + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(mapper.writeValueAsString(requestSaveComment)) + .when() + .post("/api/articles/{slug}/comments", makeSlug("타이틀-1")); + + response.then() + .assertThat().statusCode(HttpStatus.CREATED.value()); + commentId = response.jsonPath().getLong("id"); } @Order(24) - @DisplayName("특정(본인) 글에 커멘트 등록하는 테스트") + @DisplayName("특정 글의 전체 커멘트 조회 테스트") @Test - void when_addCommentsToArticle_expect_success_comments() throws Exception { - // given - RequestSaveComment requestSaveComment = RequestSaveComment.from("글 좋아요 ~"); - // when - // then - MockHttpServletResponse response = mockMvc.perform( - post("/api/articles/{slug}/comments", makeSlug("수정된 타이틀")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .content(mapper.writeValueAsString(requestSaveComment)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isCreated()) - .andExpect(jsonPath("id").exists()) - .andExpect(jsonPath("body").value("글 좋아요 ~")) - .andExpect(jsonPath("author.email").value("seokrae@gmail.com")) - .andExpect(jsonPath("author.userName").value("updatedUser")) - .andReturn().getResponse(); - - String contentAsString = response.getContentAsString(); - commentId = mapper.readTree(contentAsString).get("id").asLong(); + void when_get_comments_expect_success_comments() { + Response response = given() + .when() + .get("/api/articles/{slug}/comments", makeSlug("타이틀-1")); + + response.then() + .assertThat().statusCode(HttpStatus.OK.value()); } @Order(25) - @DisplayName("특정 글의 모든 커멘트 조회 테스트") + @DisplayName("커멘트 삭제 테스트") @Test - void when_getCommentsFromAnArticle_expect_success_comments() throws Exception { - mockMvc.perform( - get("/api/articles/{slug}/comments", makeSlug("수정된 타이틀")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) - ) - .andExpect(status().isOk()) - // comments 사이즈 확인 - .andExpect(jsonPath("$.commentSize").value(1)); + void when_delete_comment_expect_success_delete_comment() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .delete("/api/articles/{slug}/comments/{commentId}", makeSlug("타이틀-1"), commentId); + + response.then() + .assertThat().statusCode(HttpStatus.NO_CONTENT.value()); } @Order(26) - @DisplayName("커멘트 삭제 테스트") + @DisplayName("특정 글 삭제 테스트") @Test - void when_deleteComments_expect_success_delete_comment() throws Exception { - mockMvc.perform( - delete("/api/articles/{slug}/comments/{id}", makeSlug("수정된 타이틀"), commentId) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isNoContent()); + void when_delete_article_expect_success() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user2Token) + .when() + .delete("/api/articles/{slug}", makeSlug("타이틀-3")); + + response.then() + .assertThat().statusCode(HttpStatus.NO_CONTENT.value()); } - @Order(27) - @DisplayName("특정 글 삭제 테스트") + @DisplayName("사용자(user1) 로그아웃 테스트") @Test - void when_deleteArticle_expect_success_deleted_article() throws Exception { - mockMvc.perform( - delete("/api/articles/{slug}", makeSlug("수정된 타이틀")) - .header(AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isNoContent()); + void when_logout_expect_success_user1_logout() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user1Token) + .when() + .delete("/api/users/logout"); + + response.then() + .assertThat().statusCode(HttpStatus.NO_CONTENT.value()); } @Order(28) - @DisplayName("사용자(seokrae) 로그아웃 테스트") - @Test - void when_logout_expect_success_seokrae_logout() throws Exception { - mockMvc.perform( - delete("/api/users/logout") - .header(HttpHeaders.AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isNoContent()); - } - - @Order(29) - @DisplayName("사용자(seok) 로그아웃 테스트") + @DisplayName("사용자(user2) 로그아웃 테스트") @Test - void when_logout_expect_success_seok_logout() throws Exception { - mockMvc.perform( - delete("/api/users/logout") - .header(HttpHeaders.AUTHORIZATION, BEARER_PREFIX + sr_token) - ) - .andExpect(status().isNoContent()); + void when_logout_expect_success_user2_logout() { + Response response = given() + .header(AUTHORIZATION, BEARER_PREFIX + user2Token) + .when() + .delete("/api/users/logout"); + + response.then() + .assertThat().statusCode(HttpStatus.NO_CONTENT.value()); } } diff --git a/src/test/java/com/example/realworld/application/users/UserFixture.java b/src/test/java/com/example/realworld/application/users/UserFixture.java index eb4b2f4..726674f 100644 --- a/src/test/java/com/example/realworld/application/users/UserFixture.java +++ b/src/test/java/com/example/realworld/application/users/UserFixture.java @@ -11,8 +11,8 @@ public class UserFixture { private UserFixture() { } - public static RequestUpdateUser getRequestUpdateUser(String email, String updatedUserName, String password, String image, String bio) { - return RequestUpdateUser.of(email, updatedUserName, password, image, bio); + public static RequestUpdateUser getRequestUpdateUser(String updatedUserName, String password, String image, String bio) { + return RequestUpdateUser.of(updatedUserName, password, image, bio); } public static RequestSaveUser getRequestSaveUser(String email, String userName) { diff --git a/src/test/java/com/example/realworld/application/users/service/UserBusinessServiceTest.java b/src/test/java/com/example/realworld/application/users/service/UserBusinessServiceTest.java index b9d83ec..30ea636 100644 --- a/src/test/java/com/example/realworld/application/users/service/UserBusinessServiceTest.java +++ b/src/test/java/com/example/realworld/application/users/service/UserBusinessServiceTest.java @@ -97,7 +97,7 @@ void when_updateUser_expect_success_change_username() { // given String currentUserEmail = "seokrae@gmail.com"; RequestSaveUser saveUser = getRequestSaveUser(currentUserEmail, "seok"); - RequestUpdateUser updateUser = getRequestUpdateUser(currentUserEmail, "seokrae", "12345", "/image.png", "hello bio"); + RequestUpdateUser updateUser = getRequestUpdateUser("seokrae", "12345", "/image.png", "hello bio"); // when userBusinessService.postUser(saveUser); ResponseUser updatedUser = userBusinessService.updateUser(currentUserEmail, updateUser); @@ -111,7 +111,7 @@ void when_updateUser_expect_success_no_data() { // given String currentUserEmail = "seokrae@gmail.com"; RequestSaveUser saveUser = getRequestSaveUser(currentUserEmail, "seok"); - RequestUpdateUser updateUser = getRequestUpdateUser("", "", "", "", ""); + RequestUpdateUser updateUser = getRequestUpdateUser("", "", "", ""); // when userBusinessService.postUser(saveUser); ResponseUser updatedUser = userBusinessService.updateUser(currentUserEmail, updateUser);