-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
러너 본인 프로필 조회 기능 구현 #183
Merged
Merged
러너 본인 프로필 조회 기능 구현 #183
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c766281
refactor: runner response 는 runner 패키지로 이동
shb03323 da69486
feat: runner 프로필 조회 response 생성
shb03323 e53b0f2
refactor: 바뀐 response 패키지 적용
shb03323 70cbf92
test: IntroductionFixture 추가
shb03323 a34efdb
test: 인수테스트 추가
shb03323 633d32d
test: 중복된 테스트 제거
shb03323 326a23f
feat: runner 식별자로 runnerPost 조회 쿼리 생성
shb03323 481b588
feat: runner 식별자로 runnerPost 조회 서비스 로직 구현
shb03323 205ab3e
feat: runner 본인 프로필 조회 기능 구현
shb03323 7676cf4
Merge branch 'dev/BE' into feat/178
shb03323 480b542
refactor: auth 적용
shb03323 7f5829c
Merge branch 'dev/BE' into feat/178
shb03323 5c42883
refactor: restdocs 관련 테스트 주석 처리
shb03323 13bce4d
Merge branch 'dev/BE' into feat/178
shb03323 0e8cca6
test: runner fixture 에 introduction 추가
shb03323 852de63
Merge branch 'dev/BE' into feat/178
shb03323 711f436
refactor: controller 메소드 이름 변경
shb03323 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 32 additions & 0 deletions
32
...end/baton/src/main/java/touch/baton/domain/runner/controller/RunnerProfileController.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,32 @@ | ||
package touch.baton.domain.runner.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import touch.baton.domain.oauth.controller.resolver.AuthRunnerPrincipal; | ||
import touch.baton.domain.runner.Runner; | ||
import touch.baton.domain.runner.controller.response.RunnerMyProfileResponse; | ||
import touch.baton.domain.runner.controller.response.RunnerResponse; | ||
import touch.baton.domain.runnerpost.controller.response.RunnerPostResponse; | ||
import touch.baton.domain.runnerpost.service.RunnerPostService; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/profile/runner") | ||
@RestController | ||
public class RunnerProfileController { | ||
|
||
private final RunnerPostService runnerPostService; | ||
|
||
@GetMapping | ||
public ResponseEntity<RunnerMyProfileResponse> read(@AuthRunnerPrincipal final Runner runner) { | ||
final RunnerResponse.Mine me = RunnerResponse.Mine.from(runner); | ||
final List<RunnerPostResponse.Mine> runnerPosts = runnerPostService.readRunnerPostsByRunnerId(runner.getId()).stream() | ||
.map(RunnerPostResponse.Mine::from) | ||
.toList(); | ||
return ResponseEntity.ok(new RunnerMyProfileResponse(me, runnerPosts)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../src/main/java/touch/baton/domain/runner/controller/response/RunnerMyProfileResponse.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,10 @@ | ||
package touch.baton.domain.runner.controller.response; | ||
|
||
import touch.baton.domain.runnerpost.controller.response.RunnerPostResponse; | ||
|
||
import java.util.List; | ||
|
||
public record RunnerMyProfileResponse(RunnerResponse.Mine profile, | ||
List<RunnerPostResponse.Mine> runnerPosts | ||
) { | ||
} |
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
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
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
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
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
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
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
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
60 changes: 60 additions & 0 deletions
60
backend/baton/src/test/java/touch/baton/controller/runner/RunnerAssuredSupport.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,60 @@ | ||
package touch.baton.controller.runner; | ||
|
||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import touch.baton.assure.common.AssuredSupport; | ||
import touch.baton.domain.runner.controller.response.RunnerMyProfileResponse; | ||
|
||
import static org.assertj.core.api.SoftAssertions.assertSoftly; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class RunnerAssuredSupport { | ||
|
||
private RunnerAssuredSupport() { | ||
} | ||
|
||
public static RunnerClientRequestBuilder 클라이언트_요청() { | ||
return new RunnerClientRequestBuilder(); | ||
} | ||
|
||
public static class RunnerClientRequestBuilder { | ||
|
||
private ExtractableResponse<Response> response; | ||
|
||
public RunnerClientRequestBuilder 러너_액세스_토큰으로_러너_프로필을_조회한다(final String 러너_액세스_토큰) { | ||
response = AssuredSupport.get("/api/v1/profile/runner", 러너_액세스_토큰); | ||
return this; | ||
} | ||
|
||
public RunnerServerResponseBuilder 서버_응답() { | ||
return new RunnerServerResponseBuilder(response); | ||
} | ||
} | ||
|
||
public static class RunnerServerResponseBuilder { | ||
|
||
private final ExtractableResponse<Response> response; | ||
|
||
public RunnerServerResponseBuilder(final ExtractableResponse<Response> response) { | ||
this.response = response; | ||
} | ||
|
||
public void 러너_본인_프로필_조회_성공을_검증한다(final RunnerMyProfileResponse 러너_프로필_응답) { | ||
final RunnerMyProfileResponse actual = this.response.as(RunnerMyProfileResponse.class); | ||
|
||
assertSoftly(softly -> { | ||
softly.assertThat(actual.profile().name()).isEqualTo(러너_프로필_응답.profile().name()); | ||
softly.assertThat(actual.profile().imageUrl()).isEqualTo(러너_프로필_응답.profile().imageUrl()); | ||
softly.assertThat(actual.profile().githubUrl()).isEqualTo(러너_프로필_응답.profile().githubUrl()); | ||
softly.assertThat(actual.profile().introduction()).isEqualTo(러너_프로필_응답.profile().introduction()); | ||
softly.assertThat(actual.runnerPosts().size()).isEqualTo(러너_프로필_응답.runnerPosts().size()); | ||
softly.assertThat(actual.runnerPosts().get(0).runnerPostId()).isEqualTo(러너_프로필_응답.runnerPosts().get(0).runnerPostId()); | ||
softly.assertThat(actual.runnerPosts().get(0).title()).isEqualTo(러너_프로필_응답.runnerPosts().get(0).title()); | ||
softly.assertThat(actual.runnerPosts().get(0).deadline()).isEqualToIgnoringSeconds(러너_프로필_응답.runnerPosts().get(0).deadline()); | ||
softly.assertThat(actual.runnerPosts().get(0).tags()).isEqualTo(러너_프로필_응답.runnerPosts().get(0).tags()); | ||
softly.assertThat(actual.runnerPosts().get(0).reviewStatus()).isEqualTo(러너_프로필_응답.runnerPosts().get(0).reviewStatus()); | ||
} | ||
); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/baton/src/test/java/touch/baton/controller/runner/RunnerProfileAssuredReadTest.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,24 @@ | ||
package touch.baton.controller.runner; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import touch.baton.config.AssuredTestConfig; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class RunnerProfileAssuredReadTest extends AssuredTestConfig { | ||
|
||
@Test | ||
void 액세스_토큰으로_러너_본인의_정보_조회에_성공한다() { | ||
// TODO: Access Token 으로 바꿔야함 | ||
// final String accessToken = "abc123"; | ||
// final Member memberHyena = memberRepository.save(MemberFixture.createHyena()); | ||
// final Runner runnerHyena = runnerRepository.save(RunnerFixture.create(totalRating(0), Grade.BARE_FOOT, introduction("hello"), memberHyena)); | ||
// final RunnerPost runnerPost = runnerPostRepository.save(RunnerPostFixture.create(runnerHyena, deadline(LocalDateTime.now().plusHours(100)))); | ||
// | ||
// RunnerAssuredSupport | ||
// .클라이언트_요청().러너_액세스_토큰으로_러너_프로필을_조회한다(accessToken) | ||
// .서버_응답().러너_본인_프로필_조회_성공을_검증한다(new RunnerMyProfileResponse( | ||
// RunnerResponse.Mine.from(runnerHyena), | ||
// List.of(RunnerPostResponse.Mine.from(runnerPost) | ||
// ))); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...aton/src/test/java/touch/baton/document/profile/runner/read/RunnerProfileReadApiTest.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,24 @@ | ||
package touch.baton.document.profile.runner.read; | ||
|
||
//@WebMvcTest(RunnerProfileController.class) | ||
//public class RunnerProfileReadApiTest extends RestdocsConfig { | ||
|
||
// @MockBean | ||
// private RunnerPostService runnerPostService; | ||
|
||
// @DisplayName("러너 프로필 조회 API") | ||
// @Test | ||
// void read() throws Exception { | ||
// // TODO: 로그인 들어오면 작성하겠삼. | ||
// // given | ||
// final Runner runner = RunnerFixture.createRunner(MemberFixture.createHyena()); | ||
// final Deadline deadline = deadline(LocalDateTime.now().plusHours(100)); | ||
// final Tag javaTag = TagFixture.create(tagName("자바"), tagCount(10)); | ||
// final RunnerPost runnerPost = RunnerPostFixture.create(runner, deadline, List.of(javaTag)); | ||
// final RunnerPost spyRunnerPost = spy(runnerPost); | ||
// | ||
// // when | ||
// | ||
// // then | ||
// } | ||
//} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readXXX로 해주세요