-
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.
* feat: Runner 기술 태그 추가 * feat: Runner 본인 프로필 응답 객체 추가 * test: Runner 본인 프로필 조회 인수 테스트 추가 * test: Runner 생성시 RunnerTechnicalTags 생성시 추가 * test: 인수 테스트 truncate Listener 추가 * feat: Runner 본인 프로필 조회 컨트롤러 추가 * docs: Runner 본인 프로필 조회 API 문서 * docs: Runner 본인 프로필 조회 API 문서 내부 수정 * test: 인숱 테스트 데이터 삭제 메서드 수정
- Loading branch information
Showing
22 changed files
with
400 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ifndef::snippets[] | ||
:snippets: ../../../build/generated-snippets | ||
endif::[] | ||
:doctype: investment | ||
:icons: font | ||
:source-highlighter: highlight.js | ||
:toc: left | ||
:toclevels: 2 | ||
:sectlinks: | ||
:operation-http-request-title: Example Request | ||
:operation-http-response-title: Example Response | ||
|
||
== *러너 본인 프로필 조회* | ||
|
||
=== *러너 본인 프로필 조회 API* | ||
|
||
==== *Http Request* | ||
include::{snippets}/../../build/generated-snippets/runner-profile-read-api-test/read-my-profile-by-token/http-request.adoc[] | ||
|
||
==== *Http Request Headers* | ||
include::{snippets}/../../build/generated-snippets/runner-profile-read-api-test/read-my-profile-by-token/request-headers.adoc[] | ||
|
||
==== *Http Response* | ||
include::{snippets}/../../build/generated-snippets/runner-profile-read-api-test/read-my-profile-by-token/http-response.adoc[] | ||
|
||
==== *Http Response Fields* | ||
include::{snippets}/../../build/generated-snippets/runner-profile-read-api-test/read-my-profile-by-token/response-fields.adoc[] |
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
30 changes: 30 additions & 0 deletions
30
backend/baton/src/test/java/touch/baton/assure/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,30 @@ | ||
package touch.baton.assure.runner; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import touch.baton.config.AssuredTestConfig; | ||
import touch.baton.domain.member.Member; | ||
import touch.baton.domain.runner.Runner; | ||
import touch.baton.fixture.domain.MemberFixture; | ||
import touch.baton.fixture.domain.RunnerFixture; | ||
|
||
import static touch.baton.assure.runner.RunnerProfileAssuredSupport.러너_본인_프로필_응답; | ||
import static touch.baton.fixture.vo.IntroductionFixture.introduction; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
class RunnerProfileAssuredReadTest extends AssuredTestConfig { | ||
|
||
@Test | ||
void 러너_본인_프로필을_가지고_있는_토큰으로_조회에_성공한다() { | ||
final Member 사용자_헤나 = memberRepository.save(MemberFixture.createHyena()); | ||
final Runner 러너_헤나 = runnerRepository.save(RunnerFixture.create(introduction("안녕하세요"), 사용자_헤나)); | ||
final String 로그인용_토큰 = login(사용자_헤나.getSocialId().getValue()); | ||
|
||
RunnerProfileAssuredSupport | ||
.클라이언트_요청() | ||
.토큰으로_로그인한다(로그인용_토큰) | ||
.러너_본인_프로필을_가지고_있는_토큰으로_조회한다() | ||
|
||
.서버_응답() | ||
.러너_본인_프로필_조회_성공을_검증한다(러너_본인_프로필_응답(러너_헤나)); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
backend/baton/src/test/java/touch/baton/assure/runner/RunnerProfileAssuredSupport.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,67 @@ | ||
package touch.baton.assure.runner; | ||
|
||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import touch.baton.assure.common.AssuredSupport; | ||
import touch.baton.domain.runner.Runner; | ||
import touch.baton.domain.runner.controller.response.RunnerResponse; | ||
|
||
import static org.assertj.core.api.SoftAssertions.assertSoftly; | ||
|
||
public class RunnerProfileAssuredSupport { | ||
|
||
private RunnerProfileAssuredSupport() { | ||
} | ||
|
||
public static RunnerClientRequestBuilder 클라이언트_요청() { | ||
return new RunnerClientRequestBuilder(); | ||
} | ||
|
||
public static RunnerResponse.MyProfile 러너_본인_프로필_응답(final Runner 러너) { | ||
return RunnerResponse.MyProfile.from(러너); | ||
} | ||
|
||
public static class RunnerClientRequestBuilder { | ||
|
||
private ExtractableResponse<Response> response; | ||
|
||
private String accessToken; | ||
|
||
public RunnerClientRequestBuilder 토큰으로_로그인한다(final String 토큰) { | ||
this.accessToken = 토큰; | ||
return this; | ||
} | ||
|
||
public RunnerClientRequestBuilder 러너_본인_프로필을_가지고_있는_토큰으로_조회한다() { | ||
response = AssuredSupport.get("/api/v1/profile/runner/me", accessToken); | ||
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 RunnerResponse.MyProfile 러너_본인_프로필_응답) { | ||
final RunnerResponse.MyProfile actual = this.response.as(RunnerResponse.MyProfile.class); | ||
|
||
assertSoftly(softly -> { | ||
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
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
39 changes: 39 additions & 0 deletions
39
backend/baton/src/test/java/touch/baton/config/AssuredTestExecutionListener.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,39 @@ | ||
package touch.baton.config; | ||
|
||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.test.context.TestContext; | ||
import org.springframework.test.context.support.AbstractTestExecutionListener; | ||
|
||
import java.util.List; | ||
|
||
public class AssuredTestExecutionListener extends AbstractTestExecutionListener { | ||
|
||
@Override | ||
public void afterTestMethod(final TestContext testContext) { | ||
final JdbcTemplate jdbcTemplate = getJdbcTemplate(testContext); | ||
final List<String> truncateQueries = getTruncateQueries(jdbcTemplate); | ||
truncateTables(jdbcTemplate, truncateQueries); | ||
} | ||
|
||
private List<String> getTruncateQueries(final JdbcTemplate jdbcTemplate) { | ||
return jdbcTemplate.queryForList(""" | ||
SELECT Concat('TRUNCATE TABLE ', TABLE_NAME, ';') AS q | ||
FROM INFORMATION_SCHEMA.TABLES | ||
WHERE TABLE_SCHEMA = 'PUBLIC' | ||
""", String.class); | ||
} | ||
|
||
private JdbcTemplate getJdbcTemplate(final TestContext testContext) { | ||
return testContext.getApplicationContext().getBean(JdbcTemplate.class); | ||
} | ||
|
||
private void truncateTables(final JdbcTemplate jdbcTemplate, final List<String> truncateQueries) { | ||
execute(jdbcTemplate, "SET REFERENTIAL_INTEGRITY FALSE"); | ||
truncateQueries.forEach(v -> execute(jdbcTemplate, v)); | ||
execute(jdbcTemplate, "SET REFERENTIAL_INTEGRITY TRUE"); | ||
} | ||
|
||
private void execute(final JdbcTemplate jdbcTemplate, final String query) { | ||
jdbcTemplate.execute(query); | ||
} | ||
} |
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.