-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/com/funeat/member/presentation/MemberApiController.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,27 @@ | ||
package com.funeat.member.presentation; | ||
|
||
import com.funeat.member.application.MemberService; | ||
import com.funeat.member.dto.MemberRequest; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class MemberApiController { | ||
|
||
private final MemberService memberService; | ||
|
||
public MemberApiController(final MemberService memberService) { | ||
this.memberService = memberService; | ||
} | ||
|
||
@PutMapping("/api/members/{memberId}") | ||
public ResponseEntity<Void> putMemberProfile(@PathVariable final Long memberId, | ||
@RequestBody final MemberRequest request) { | ||
memberService.modify(memberId, request); | ||
|
||
return ResponseEntity.ok().build(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
backend/src/test/java/com/funeat/acceptance/member/MemberAcceptanceTest.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,45 @@ | ||
package com.funeat.acceptance.member; | ||
|
||
import static com.funeat.acceptance.common.CommonSteps.STATUS_CODE를_검증한다; | ||
import static com.funeat.acceptance.common.CommonSteps.정상_처리; | ||
import static io.restassured.RestAssured.given; | ||
|
||
import com.funeat.acceptance.common.AcceptanceTest; | ||
import com.funeat.member.domain.Member; | ||
import com.funeat.member.dto.MemberRequest; | ||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class MemberAcceptanceTest extends AcceptanceTest { | ||
|
||
@Test | ||
void 사용자_정보를_수정하다() { | ||
// given | ||
final var member = new Member("before", "http://www.before.com", "1"); | ||
final var memberId = 멤버_추가_요청(member); | ||
|
||
final var request = new MemberRequest("after", "http://www.after.com"); | ||
|
||
// when | ||
final var response = 사용자_정보_수정_요청(memberId, request); | ||
|
||
// then | ||
STATUS_CODE를_검증한다(response, 정상_처리); | ||
} | ||
|
||
private Long 멤버_추가_요청(final Member member) { | ||
return memberRepository.save(member).getId(); | ||
} | ||
|
||
private ExtractableResponse<Response> 사용자_정보_수정_요청(final Long memberId, final MemberRequest request) { | ||
return given() | ||
.contentType("application/json") | ||
.body(request) | ||
.when() | ||
.put("/api/members/{memberId}", memberId) | ||
.then() | ||
.extract(); | ||
} | ||
} |