-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: 인수 테스트 Jwt Mocking 추가 * feat: 서포터 프로필 응답 객체 추가 * test: 서포터 프로필 조회 인수 테스트 추가 * feat: 서포터와 사용자 패치 조인 기능 추가 * feat: 서포터 프로필 조회 서비스 기능 추가 * feat: 서포터 프로필 조회 API 추가
- Loading branch information
Showing
13 changed files
with
383 additions
and
23 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...ton/src/main/java/touch/baton/domain/supporter/controller/SupporterProfileController.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 touch.baton.domain.supporter.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import touch.baton.domain.supporter.Supporter; | ||
import touch.baton.domain.supporter.controller.response.SupporterResponse; | ||
import touch.baton.domain.supporter.service.SupporterService; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/profile/supporter") | ||
@RestController | ||
public class SupporterProfileController { | ||
|
||
private final SupporterService supporterService; | ||
|
||
@GetMapping("/{supporterId}") | ||
public ResponseEntity<SupporterResponse.Profile> readProfileBySupporterId(@PathVariable final Long supporterId) { | ||
final Supporter foundSupporter = supporterService.readBySupporterId(supporterId); | ||
final SupporterResponse.Profile response = SupporterResponse.Profile.from(foundSupporter); | ||
|
||
return ResponseEntity.ok(response); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
backend/baton/src/main/java/touch/baton/domain/supporter/repository/SupporterRepository.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 |
---|---|---|
@@ -1,7 +1,19 @@ | ||
package touch.baton.domain.supporter.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import touch.baton.domain.supporter.Supporter; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SupporterRepository extends JpaRepository<Supporter, Long> { | ||
|
||
@Query(""" | ||
select s | ||
from Supporter s | ||
join fetch Member m on s.member.id = m.id | ||
where s.id = :supporterId | ||
""") | ||
Optional<Supporter> joinMemberBySupporterId(@Param("supporterId") final Long supporterId); | ||
} |
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
27 changes: 27 additions & 0 deletions
27
...end/baton/src/test/java/touch/baton/assure/supporter/SupporterProfileAssuredReadTest.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 touch.baton.assure.supporter; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import touch.baton.config.AssuredTestConfig; | ||
import touch.baton.domain.member.Member; | ||
import touch.baton.domain.supporter.Supporter; | ||
import touch.baton.fixture.domain.MemberFixture; | ||
import touch.baton.fixture.domain.SupporterFixture; | ||
|
||
import static touch.baton.assure.supporter.SupporterProfileAssuredSupport.서포터_프로필_응답; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
class SupporterProfileAssuredReadTest extends AssuredTestConfig { | ||
|
||
@Test | ||
void 서포터_프로필을_조회한다() { | ||
final Member 사용자_헤나 = memberRepository.save(MemberFixture.createHyena()); | ||
final Supporter 서포터_헤나 = supporterRepository.save(SupporterFixture.create(사용자_헤나)); | ||
|
||
SupporterProfileAssuredSupport | ||
.클라이언트_요청() | ||
.서포터_프로필을_서포터_식별자값으로_조회한다(서포터_헤나.getId()) | ||
|
||
.서버_응답() | ||
.서포터_프로필_조회_성공을_검증한다(서포터_프로필_응답(서포터_헤나)); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
backend/baton/src/test/java/touch/baton/assure/supporter/SupporterProfileAssuredSupport.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,61 @@ | ||
package touch.baton.assure.supporter; | ||
|
||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import touch.baton.assure.common.AssuredSupport; | ||
import touch.baton.domain.supporter.Supporter; | ||
import touch.baton.domain.supporter.controller.response.SupporterResponse; | ||
|
||
import static org.assertj.core.api.SoftAssertions.assertSoftly; | ||
|
||
public class SupporterProfileAssuredSupport { | ||
|
||
private SupporterProfileAssuredSupport() { | ||
} | ||
|
||
public static SupporterClientRequestBuilder 클라이언트_요청() { | ||
return new SupporterClientRequestBuilder(); | ||
} | ||
|
||
public static SupporterResponse.Profile 서포터_프로필_응답(final Supporter 서포터) { | ||
return SupporterResponse.Profile.from(서포터); | ||
} | ||
|
||
public static class SupporterClientRequestBuilder { | ||
|
||
private ExtractableResponse<Response> response; | ||
|
||
public SupporterClientRequestBuilder 서포터_프로필을_서포터_식별자값으로_조회한다(final Long 서포터_식별자값) { | ||
response = AssuredSupport.get("/api/v1/profile/supporter/{supporterId}", "supporterId", 서포터_식별자값); | ||
return this; | ||
} | ||
|
||
public SupporterServerResponseBuilder 서버_응답() { | ||
return new SupporterServerResponseBuilder(response); | ||
} | ||
} | ||
|
||
public static class SupporterServerResponseBuilder { | ||
|
||
private final ExtractableResponse<Response> response; | ||
|
||
public SupporterServerResponseBuilder(final ExtractableResponse<Response> response) { | ||
this.response = response; | ||
} | ||
|
||
public void 서포터_프로필_조회_성공을_검증한다(final SupporterResponse.Profile 서포터_프로필_응답) { | ||
final SupporterResponse.Profile actual = this.response.as(SupporterResponse.Profile.class); | ||
|
||
assertSoftly(softly -> { | ||
softly.assertThat(actual.supporterId()).isEqualTo(서포터_프로필_응답.supporterId()); | ||
softly.assertThat(actual.name()).isEqualTo(서포터_프로필_응답.name()); | ||
softly.assertThat(actual.company()).isEqualTo(서포터_프로필_응답.company()); | ||
softly.assertThat(actual.imageUrl()).isEqualTo(서포터_프로필_응답.imageUrl()); | ||
softly.assertThat(actual.githubUrl()).isEqualTo(서포터_프로필_응답.githubUrl()); | ||
softly.assertThat(actual.introduction()).isEqualTo(서포터_프로필_응답.introduction()); | ||
softly.assertThat(actual.technicalTags()).isEqualTo(서포터_프로필_응답.technicalTags()); | ||
} | ||
); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.