Skip to content

Commit

Permalink
feat: 정보 수정 컨트롤러 추가 및 인수테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
70825 committed Aug 1, 2023
1 parent c929828 commit 5e6da70
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
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();
}
}
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();
}
}

0 comments on commit 5e6da70

Please sign in to comment.