Skip to content

Commit

Permalink
Merge branch 'dev/BE' into deploy/merge
Browse files Browse the repository at this point in the history
  • Loading branch information
cookienc committed Feb 21, 2024
2 parents 98b27f4 + 7504019 commit 2c418be
Show file tree
Hide file tree
Showing 16 changed files with 411 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backend/baton/src/docs/asciidoc/RunnerPostReadApi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,17 @@ include::{snippets}/../../build/generated-snippets/tag-read-api-test/read-tags-b
===== *Http Response Fields*

include::{snippets}/../../build/generated-snippets/tag-read-api-test/read-tags-by-reduced-name/response-fields.adoc[]

==== *λŸ¬λ„ˆ κ²Œμ‹œκΈ€ μƒνƒœλ³„ 총 개수 쑰회 API*

===== *Http Request*

include::{snippets}/../../build/generated-snippets/runner-post-status-count-api-test/count-all-runner-post-by-review-status/http-request.adoc[]

===== *Http Response*

include::{snippets}/../../build/generated-snippets/runner-post-status-count-api-test/count-all-runner-post-by-review-status/http-response.adoc[]

===== *Http Response Fields*

include::{snippets}/../../build/generated-snippets/runner-post-status-count-api-test/count-all-runner-post-by-review-status/response-fields.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,9 @@ public ResponseEntity<RunnerPostResponse.Count> countRunnerPostByLoginedRunnerAn
final long runnerPostCount = runnerPostQueryService.countRunnerPostByRunnerIdAndReviewStatus(runner.getId(), reviewStatus);
return ResponseEntity.ok(RunnerPostResponse.Count.from(runnerPostCount));
}

@GetMapping("/count")
public ResponseEntity<RunnerPostResponse.StatusCount> countAllRunnerPostByReviewStatus() {
return ResponseEntity.ok(runnerPostQueryService.countAllRunnerPostByReviewStatus());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,12 @@ private static List<String> convertToTags(final RunnerPost runnerPost, final Lis
.map(runnerPostTag -> runnerPostTag.getTag().getTagName().getValue())
.toList();
}

public record StatusCount(
long notStarted,
long inProgress,
long done,
long overdue
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ select count(1)
where rp.supporter.id = :supporterId and rp.reviewStatus = :reviewStatus
""")
long countBySupporterIdAndReviewStatus(@Param("supporterId") final Long supporterId, @Param("reviewStatus") final ReviewStatus reviewStatus);


@Query("""
select count(1)
from RunnerPost rp
where rp.reviewStatus = :reviewStatus
""")
long countByReviewStatus(@Param("reviewStatus") ReviewStatus reviewStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ public long countRunnerPostBySupporterIdAndReviewStatus(final Long supporterId,
return runnerPostQueryRepository.countBySupporterIdAndReviewStatus(supporterId, reviewStatus);
}

public RunnerPostResponse.StatusCount countAllRunnerPostByReviewStatus() {
long notStartedCount = runnerPostQueryRepository.countByReviewStatus(ReviewStatus.NOT_STARTED);
long inProgressCount = runnerPostQueryRepository.countByReviewStatus(ReviewStatus.IN_PROGRESS);
long doneCount = runnerPostQueryRepository.countByReviewStatus(ReviewStatus.DONE);
long overdueCount = runnerPostQueryRepository.countByReviewStatus(ReviewStatus.OVERDUE);

return new RunnerPostResponse.StatusCount(notStartedCount, inProgressCount, doneCount, overdueCount);
}

@Transactional
public void increaseWatchedCount(final RunnerPost runnerPost) {
runnerPost.increaseWatchedCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ public static ExtractableResponse<Response> post(final String uri,
.extract();
}

public static ExtractableResponse<Response> get(final String uri) {
return RestAssured
.given().log().ifValidationFails()
.when().log().ifValidationFails()
.get(uri)
.then().log().ifError()
.extract();
}

public static ExtractableResponse<Response> get(final String uri, final PathParams pathParams) {
return RestAssured
.given().log().ifValidationFails()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package touch.baton.assure.repository;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import touch.baton.domain.runnerpost.command.repository.RunnerPostCommandRepository;

@Profile("test")
public interface TestRunnerPostCommandRepository extends RunnerPostCommandRepository {

@Transactional
@Modifying(flushAutomatically = true, clearAutomatically = true)
@Query("""
update RunnerPost rp
set rp.reviewStatus = 'OVERDUE'
where rp.id = :id
""")
void expireRunnerPost(@Param("id") Long runnerPostId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package touch.baton.assure.runnerpost;

import org.springframework.http.HttpStatus;
import touch.baton.assure.common.HttpStatusAndLocationHeader;
import touch.baton.assure.runnerpost.support.command.RunnerPostCreateSupport;
import touch.baton.assure.runnerpost.support.command.RunnerPostUpdateSupport;
import touch.baton.assure.runnerpost.support.command.applicant.RunnerPostApplicantCreateSupport;
import touch.baton.domain.member.command.Supporter;

import java.time.LocalDateTime;
import java.util.List;

import static touch.baton.assure.runnerpost.support.command.RunnerPostCreateSupport.λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_생성_μš”μ²­;
import static touch.baton.assure.runnerpost.support.command.applicant.RunnerPostApplicantCreateSupport.λŸ¬λ„ˆμ˜_μ„œν¬ν„°_선택_μš”μ²­;

public abstract class RunnerPostSteps {

public static void λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _리뷰λ₯Ό_받은_λ’€_λ¦¬λ·°μ™„λ£Œλ‘œ_λ³€κ²½ν•œλ‹€(final String λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, final String μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, final Supporter μ„œν¬ν„°) {
final Long κ²Œμ‹œκΈ€_μ‹λ³„μž = λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ—_리뷰_신청을_μ„±κ³΅ν•œλ‹€(μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, κ²Œμ‹œκΈ€_μ‹λ³„μž);
λŸ¬λ„ˆκ°€_μ„œν¬ν„°μ˜_리뷰_μ‹ μ²­_선택에_μ„±κ³΅ν•œλ‹€(μ„œν¬ν„°, λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, κ²Œμ‹œκΈ€_μ‹λ³„μž);
μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ˜_리뷰λ₯Ό_μ™„λ£Œλ‘œ_λ³€κ²½ν•˜λŠ”_것을_μ„±κ³΅ν•œλ‹€(μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, κ²Œμ‹œκΈ€_μ‹λ³„μž);
}

public static void λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _μ„œν¬ν„°κ°€_μ„ νƒλœλ‹€(final String λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, final String μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, final Supporter μ„œν¬ν„°) {
final Long κ²Œμ‹œκΈ€_μ‹λ³„μž = λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ—_리뷰_신청을_μ„±κ³΅ν•œλ‹€(μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, κ²Œμ‹œκΈ€_μ‹λ³„μž);
λŸ¬λ„ˆκ°€_μ„œν¬ν„°μ˜_리뷰_μ‹ μ²­_선택에_μ„±κ³΅ν•œλ‹€(μ„œν¬ν„°, λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, κ²Œμ‹œκΈ€_μ‹λ³„μž);
}

public static Long λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(final String λŸ¬λ„ˆ_μ—‘μ„ΈμŠ€_토큰) {
return RunnerPostCreateSupport
.ν΄λΌμ΄μ–ΈνŠΈ_μš”μ²­()
.μ•‘μ„ΈμŠ€_ν† ν°μœΌλ‘œ_λ‘œκ·ΈμΈν•œλ‹€(λŸ¬λ„ˆ_μ—‘μ„ΈμŠ€_토큰)
.λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_등둝_μš”μ²­ν•œλ‹€(
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_생성_μš”μ²­(
"ν…ŒμŠ€νŠΈμš©_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_제λͺ©",
List.of("μžλ°”", "μŠ€ν”„λ§"),
"https://test-pull-request.com",
LocalDateTime.now().plusHours(100),
"ν…ŒμŠ€νŠΈμš©_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_κ΅¬ν˜„_λ‚΄μš©",
"ν…ŒμŠ€νŠΈμš©_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_κΆκΈˆν•œ_λ‚΄μš©",
"ν…ŒμŠ€νŠΈμš©_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ°Έκ³ _사항"
))

.μ„œλ²„_응닡()
.λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_생성_성곡을_κ²€μ¦ν•œλ‹€()
.μƒμ„±ν•œ_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ˜_μ‹λ³„μžκ°’μ„_λ°˜ν™˜ν•œλ‹€();
}

public static void μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ—_리뷰_신청을_μ„±κ³΅ν•œλ‹€(final String μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, final Long λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’) {
RunnerPostApplicantCreateSupport
.ν΄λΌμ΄μ–ΈνŠΈ_μš”μ²­()
.μ•‘μ„ΈμŠ€_ν† ν°μœΌλ‘œ_λ‘œκ·ΈμΈν•œλ‹€(μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰)
.μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ—_리뷰λ₯Ό_μ‹ μ²­ν•œλ‹€(λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’, "μ•ˆλ…•ν•˜μ„Έμš”. μ„œν¬ν„°μž…λ‹ˆλ‹€.")

.μ„œλ²„_응닡()
.μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ—_리뷰_μ‹ μ²­_성곡을_κ²€μ¦ν•œλ‹€(λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’);
}

public static void λŸ¬λ„ˆκ°€_μ„œν¬ν„°μ˜_리뷰_μ‹ μ²­_선택에_μ„±κ³΅ν•œλ‹€(final Supporter μ„œν¬ν„°, final String λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, final Long λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’) {
RunnerPostUpdateSupport
.ν΄λΌμ΄μ–ΈνŠΈ_μš”μ²­()
.μ•‘μ„ΈμŠ€_ν† ν°μœΌλ‘œ_λ‘œκ·ΈμΈν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰)
.λŸ¬λ„ˆκ°€_μ„œν¬ν„°λ₯Ό_μ„ νƒν•œλ‹€(λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’, λŸ¬λ„ˆμ˜_μ„œν¬ν„°_선택_μš”μ²­(μ„œν¬ν„°.getId()))

.μ„œλ²„_응닡()
.λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ—_μ„œν¬ν„°κ°€_μ„±κ³΅μ μœΌλ‘œ_μ„ νƒλ˜μ—ˆλŠ”μ§€_ν™•μΈν•œλ‹€(new HttpStatusAndLocationHeader(HttpStatus.NO_CONTENT, "/api/v1/posts/runner"));
}

public static void μ„œν¬ν„°κ°€_λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ˜_리뷰λ₯Ό_μ™„λ£Œλ‘œ_λ³€κ²½ν•˜λŠ”_것을_μ„±κ³΅ν•œλ‹€(final String μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, final Long λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’) {
RunnerPostUpdateSupport
.ν΄λΌμ΄μ–ΈνŠΈ_μš”μ²­()
.μ•‘μ„ΈμŠ€_ν† ν°μœΌλ‘œ_λ‘œκ·ΈμΈν•œλ‹€(μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰)
.μ„œν¬ν„°κ°€_리뷰λ₯Ό_μ™„λ£Œν•˜κ³ _λ¦¬λ·°μ™„λ£Œ_λ²„νŠΌμ„_λˆ„λ₯Έλ‹€(λŸ¬λ„ˆ_κ²Œμ‹œκΈ€_μ‹λ³„μžκ°’)

.μ„œλ²„_응닡()
.λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ΄_μ„±κ³΅μ μœΌλ‘œ_리뷰_μ™„λ£Œ_μƒνƒœμΈμ§€_ν™•μΈν•œλ‹€(new HttpStatusAndLocationHeader(HttpStatus.NO_CONTENT, "/api/v1/posts/runner"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package touch.baton.assure.runnerpost.query.count;

import org.junit.jupiter.api.Test;
import touch.baton.assure.runnerpost.support.query.count.RunnerPostStatusCountAssuredSupport;
import touch.baton.config.AssuredTestConfig;
import touch.baton.config.infra.auth.oauth.authcode.FakeAuthCodes;
import touch.baton.domain.member.command.Supporter;
import touch.baton.domain.member.command.vo.SocialId;

import static touch.baton.assure.runnerpost.RunnerPostSteps.λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€;
import static touch.baton.assure.runnerpost.RunnerPostSteps.λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _리뷰λ₯Ό_받은_λ’€_λ¦¬λ·°μ™„λ£Œλ‘œ_λ³€κ²½ν•œλ‹€;
import static touch.baton.assure.runnerpost.RunnerPostSteps.λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _μ„œν¬ν„°κ°€_μ„ νƒλœλ‹€;

@SuppressWarnings("NonAsciiCharacters")
class RunnerPostStatusCountAssruedTest extends AssuredTestConfig {

@Test
void 리뷰_μƒνƒœ_별_κ²Œμ‹œκΈ€μ˜_총_개수λ₯Ό_μ‘°νšŒν•œλ‹€() {
// given
final String λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰 = oauthLoginTestManager.μ†Œμ…œ_νšŒμ›κ°€μž…μ„_μ§„ν–‰ν•œ_ν›„_μ•‘μ„ΈμŠ€_토큰을_λ°˜ν™˜ν•œλ‹€(FakeAuthCodes.hyenaAuthCode());
final String μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰 = oauthLoginTestManager.μ†Œμ…œ_νšŒμ›κ°€μž…μ„_μ§„ν–‰ν•œ_ν›„_μ•‘μ„ΈμŠ€_토큰을_λ°˜ν™˜ν•œλ‹€(FakeAuthCodes.ethanAuthCode());
final SocialId μ„œν¬ν„°_μ†Œμ…œ_아이디 = jwtTestManager.parseToSocialId(μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰);
final Supporter μ„œν¬ν„° = supporterRepository.getBySocialId(μ„œν¬ν„°_μ†Œμ…œ_아이디);

final Long 리뷰_진행쀑_κΈ€_개수 = 1L;
λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _μ„œν¬ν„°κ°€_μ„ νƒλœλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, μ„œν¬ν„°);

final Long 리뷰_μ™„λ£Œ_κΈ€_개수 = 2L;
λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _리뷰λ₯Ό_받은_λ’€_λ¦¬λ·°μ™„λ£Œλ‘œ_λ³€κ²½ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, μ„œν¬ν„°);
λŸ¬λ„ˆκ°€_κ²Œμ‹œκΈ€μ„_μž‘μ„±ν•˜κ³ _리뷰λ₯Ό_받은_λ’€_λ¦¬λ·°μ™„λ£Œλ‘œ_λ³€κ²½ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰, μ„œν¬ν„°_μ•‘μ„ΈμŠ€_토큰, μ„œν¬ν„°);

final Long 리뷰_λŒ€κΈ°μ€‘_κΈ€_개수 = 3L;
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);

final Long κΈ°κ°„_만료_κΈ€_개수 = 4L;
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _λ§ˆκ°κΈ°ν•œμ΄_μ§€λ‚˜_λ§ˆκ°λœλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _λ§ˆκ°κΈ°ν•œμ΄_μ§€λ‚˜_λ§ˆκ°λœλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _λ§ˆκ°κΈ°ν•œμ΄_μ§€λ‚˜_λ§ˆκ°λœλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _λ§ˆκ°κΈ°ν•œμ΄_μ§€λ‚˜_λ§ˆκ°λœλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);

// when, then
RunnerPostStatusCountAssuredSupport
.ν΄λΌμ΄μ–ΈνŠΈ_μš”μ²­()
.κ²Œμ‹œκΈ€μ˜_μƒνƒœλ³„λ‘œ_κ²Œμ‹œκΈ€_총_수λ₯Ό_λ°˜ν™˜ν•œλ‹€()

.μ„œλ²„_응닡()
.κ²Œμ‹œκΈ€_μƒνƒœλ³„_κ²Œμ‹œκΈ€_총_수_λ°˜ν™˜_성곡을_ν™•μΈν•œλ‹€(리뷰_λŒ€κΈ°μ€‘_κΈ€_개수, 리뷰_진행쀑_κΈ€_개수, 리뷰_μ™„λ£Œ_κΈ€_개수, κΈ°κ°„_만료_κΈ€_개수);
}

private void λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _λ§ˆκ°κΈ°ν•œμ΄_μ§€λ‚˜_λ§ˆκ°λœλ‹€(final String λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰) {
final Long 만료된_κ²Œμ‹œκΈ€ = λŸ¬λ„ˆ_κ²Œμ‹œκΈ€μ„_μƒμ„±ν•˜κ³ _κ²Œμ‹œμ„κΈ€_μ‹λ³„μžλ₯Ό_λ°˜ν™˜ν•œλ‹€(λŸ¬λ„ˆ_μ•‘μ„ΈμŠ€_토큰);
runnerPostCommandRepository.expireRunnerPost(만료된_κ²Œμ‹œκΈ€);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package touch.baton.assure.runnerpost.support.query.count;

import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.springframework.http.HttpStatus;
import touch.baton.assure.common.AssuredSupport;
import touch.baton.domain.runnerpost.query.controller.response.RunnerPostResponse;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;

@SuppressWarnings("NonAsciiCharacters")
public class RunnerPostStatusCountAssuredSupport {

private RunnerPostStatusCountAssuredSupport() {
}

public static RunnerPostStatusCountBuilder ν΄λΌμ΄μ–ΈνŠΈ_μš”μ²­() {
return new RunnerPostStatusCountBuilder();
}

public static class RunnerPostStatusCountBuilder {

private ExtractableResponse<Response> response;

public RunnerPostStatusCountBuilder κ²Œμ‹œκΈ€μ˜_μƒνƒœλ³„λ‘œ_κ²Œμ‹œκΈ€_총_수λ₯Ό_λ°˜ν™˜ν•œλ‹€() {
response = AssuredSupport.get("/api/v1/posts/runner/count");
return this;
}

public RunnerPostStatusCountResponseBuilder μ„œλ²„_응닡() {
return new RunnerPostStatusCountResponseBuilder(response);
}

public class RunnerPostStatusCountResponseBuilder {

private final ExtractableResponse<Response> response;

public RunnerPostStatusCountResponseBuilder(final ExtractableResponse<Response> 응닡) {
this.response = 응닡;
}

public void κ²Œμ‹œκΈ€_μƒνƒœλ³„_κ²Œμ‹œκΈ€_총_수_λ°˜ν™˜_성곡을_ν™•μΈν•œλ‹€(final Long 리뷰_λŒ€κΈ°μ€‘_κΈ€_개수,
final Long 리뷰_진행쀑_κΈ€_개수,
final Long 리뷰_μ™„λ£Œ_κΈ€_개수,
final Long κΈ°κ°„_만료_κΈ€_개수
) {
final RunnerPostResponse.StatusCount actual = response.as(RunnerPostResponse.StatusCount.class);

assertAll(
() -> assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()),
() -> assertThat(actual.notStarted()).isEqualTo(리뷰_λŒ€κΈ°μ€‘_κΈ€_개수),
() -> assertThat(actual.inProgress()).isEqualTo(리뷰_진행쀑_κΈ€_개수),
() -> assertThat(actual.done()).isEqualTo(리뷰_μ™„λ£Œ_κΈ€_개수),
() -> assertThat(actual.overdue()).isEqualTo(κΈ°κ°„_만료_κΈ€_개수)
);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import touch.baton.assure.repository.TestNotificationCommandRepository;
import touch.baton.assure.repository.TestRankQueryRepository;
import touch.baton.assure.repository.TestRefreshTokenRepository;
import touch.baton.assure.repository.TestRunnerPostCommandRepository;
import touch.baton.assure.repository.TestRunnerPostQueryRepository;
import touch.baton.assure.repository.TestRunnerQueryRepository;
import touch.baton.assure.repository.TestSupporterQueryRepository;
Expand All @@ -41,6 +42,9 @@ public abstract class AssuredTestConfig {
@Autowired
protected TestRunnerQueryRepository runnerRepository;

@Autowired
protected TestRunnerPostCommandRepository runnerPostCommandRepository;

@Autowired
protected TestSupporterQueryRepository supporterRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ protected Supporter persistSupporter(final ReviewCount reviewCount, final Member
return supporter;
}

protected RunnerPost persistRunnerPost(final RunnerPost runnerPost) {
em.persist(runnerPost);
return runnerPost;
}

protected RunnerPost persistRunnerPost(final Runner runner) {
final RunnerPost runnerPost = RunnerPostFixture.create(runner, deadline(LocalDateTime.now().plusHours(100)));
em.persist(runnerPost);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package touch.baton.document.runnerpost.read;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.restdocs.payload.JsonFieldType;
import touch.baton.config.RestdocsConfig;
import touch.baton.domain.runnerpost.query.controller.response.RunnerPostResponse;

import static org.mockito.BDDMockito.when;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

class RunnerPostStatusCountApiTest extends RestdocsConfig {

@DisplayName("κ²Œμ‹œκΈ€ μƒνƒœ 별 총 개수 λ°˜ν™˜ API κ΅¬ν˜„")
@Test
void countAllRunnerPostByReviewStatus() throws Exception {
// when
when(runnerPostQueryService.countAllRunnerPostByReviewStatus())
.thenReturn(new RunnerPostResponse.StatusCount(1L, 2L, 3L, 4L));

// then
mockMvc.perform(get("/api/v1/posts/runner/count"))
.andExpect(status().isOk())
.andDo(restDocs.document(
responseFields(
fieldWithPath("notStarted").type(JsonFieldType.NUMBER).description("리뷰_λŒ€κΈ°μ€‘_κ²Œμ‹œκΈ€_총_수"),
fieldWithPath("inProgress").type(JsonFieldType.NUMBER).description("리뷰_진행쀑_κ²Œμ‹œκΈ€_총_수"),
fieldWithPath("done").type(JsonFieldType.NUMBER).description("리뷰_μ™„λ£Œ_κ²Œμ‹œκΈ€_총_수"),
fieldWithPath("overdue").type(JsonFieldType.NUMBER).description("κΈ°κ°„_만료_κ²Œμ‹œκΈ€_총_수")
))
);
}
}
Loading

0 comments on commit 2c418be

Please sign in to comment.