fix: OpenAPI 서버 URL 설정 및 Vote 통합 테스트 추가#171
Conversation
Walkthrough투표 기능의 API 계층(생성/조회 엔드포인트) 및 데이터 계층(Repository의 저장/조회/필터링/정렬) 통합 테스트를 추가하고, OpenAPI 서버 URL을 환경별로 구성하는 변경입니다. ChangesVote Feature Integration Testing
OpenAPI Documentation Configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
빌드 실패 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java (2)
247-249: ⚡ Quick win사용되지 않는 변수를 제거하세요.
responseBody변수가 선언되었지만 사용되지 않습니다. 이 라인을 제거하거나, 응답에서voteId를 파싱하여 사용하는 것이 일관성 있습니다.♻️ 제안
- // voteId 추출 - String responseBody = createResult.getResponse().getContentAsString(); - Long voteId = voteRepository.findAll().get(0).getId(); + // voteId 추출 + Long voteId = voteRepository.findAll().get(0).getId();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java` around lines 247 - 249, Remove the unused local variable responseBody declared from createResult.getResponse().getContentAsString(); either delete that line or replace its usage by parsing the created voteId from the response body and using it instead of fetching voteRepository.findAll().get(0).getId(); update the test to use the parsed voteId (from createResult) for subsequent assertions or remove the unused responseBody altogether so only voteId (from either the response or repository) remains in VoteApiIntegrationTest.
180-216: ⚡ Quick win테스트 이름과 실제 검증 내용이 일치하지 않습니다.
테스트 이름은 "endAt이 정확히 계산된다"를 주장하지만, 실제로는
isNotEmpty()와isNotNull()만 검증합니다.VoteRepositoryIntegrationTest처럼 각 duration에 대해 계산된 endAt 값을 명시적으로 검증해야 합니다.♻️ 계산된 endAt 값을 검증하는 개선안
`@Test` - `@DisplayName`("다양한 duration으로 투표 생성 시 endAt이 정확히 계산된다") - void 다양한_duration으로_투표_생성시_endAt_계산_확인() throws Exception { + `@DisplayName`("다양한 duration으로 투표 생성 시 endAt이 응답에 포함된다") + void 다양한_duration으로_투표_생성시_endAt_포함_확인() throws Exception {또는 실제 계산 검증을 추가:
// 각 duration별로 endAt 차이를 검증 Map<String, Duration> durationMap = Map.of( "HOURS_1", Duration.ofHours(1), "HOURS_6", Duration.ofHours(6), "HOURS_12", Duration.ofHours(12), "HOURS_24", Duration.ofHours(24) ); for (Vote vote : votes) { // title에서 duration 추출 후 endAt 차이 검증 Instant expectedMinEndAt = vote.getCreatedAt().plus(durationMap.get(vote.getTitle().replace("투표 ", ""))); assertThat(vote.getEndAt()).isAfterOrEqualTo(expectedMinEndAt); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java` around lines 180 - 216, The test method 다양한_duration으로_투표_생성시_endAt_계산_확인() only asserts presence of endAt but the name claims precise calculation; update the test to compute expected durations and assert endAt is correctly computed per vote. After creating votes with mockMvc in that test, build a Map<String, Duration> for "HOURS_1","HOURS_6","HOURS_12","HOURS_24", load persisted Vote entities via voteRepository.findAll(), extract the duration key from vote.getTitle() (or from the request context), then assert vote.getEndAt().isAfterOrEqualTo(vote.getCreatedAt().plus(expectedDuration)) (or sufficiently close) for each Vote to validate exact endAt calculation rather than only non-null checks. Ensure assertions reference the test method name 다양한_duration으로_투표_생성시_endAt_계산_확인, Vote.getCreatedAt(), and Vote.getEndAt().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java`:
- Around line 247-249: Remove the unused local variable responseBody declared
from createResult.getResponse().getContentAsString(); either delete that line or
replace its usage by parsing the created voteId from the response body and using
it instead of fetching voteRepository.findAll().get(0).getId(); update the test
to use the parsed voteId (from createResult) for subsequent assertions or remove
the unused responseBody altogether so only voteId (from either the response or
repository) remains in VoteApiIntegrationTest.
- Around line 180-216: The test method 다양한_duration으로_투표_생성시_endAt_계산_확인() only
asserts presence of endAt but the name claims precise calculation; update the
test to compute expected durations and assert endAt is correctly computed per
vote. After creating votes with mockMvc in that test, build a Map<String,
Duration> for "HOURS_1","HOURS_6","HOURS_12","HOURS_24", load persisted Vote
entities via voteRepository.findAll(), extract the duration key from
vote.getTitle() (or from the request context), then assert
vote.getEndAt().isAfterOrEqualTo(vote.getCreatedAt().plus(expectedDuration)) (or
sufficiently close) for each Vote to validate exact endAt calculation rather
than only non-null checks. Ensure assertions reference the test method name
다양한_duration으로_투표_생성시_endAt_계산_확인, Vote.getCreatedAt(), and Vote.getEndAt().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d1df79e3-c0f4-48cb-abff-92276c7ce2a3
📒 Files selected for processing (4)
src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.javasrc/integrationTest/java/com/ject/vs/vote/domain/VoteRepositoryIntegrationTest.javasrc/main/java/com/ject/vs/config/OpenApiConfig.javasrc/main/resources/application-prod.yml
📌 관련 이슈
🔍 작업 내용
Swagger UI가 프로덕션 환경에서 올바른 서버 URL을 사용하지 못하는 문제를 수정하고,
Vote 도메인에 대한 통합 테스트를 추가합니다.
📝 변경 사항
OpenApiConfig:springdoc.server-url환경변수를 주입받아 값이 존재할 경우 OpenAPI 서버 목록에 동적으로 등록application-prod.yml: 프로덕션 서버 URL(https://api.vs.io.kr)을springdoc.server-url로 명시VoteApiIntegrationTest: Vote API 전체 플로우에 대한 통합 테스트 추가VoteRepositoryIntegrationTest: Vote Repository 쿼리에 대한 통합 테스트 추가💬 리뷰어에게
serverUrl이 비어 있을 경우 서버 목록을 설정하지 않아 로컬 환경에서는 기존 동작이 그대로 유지됩니다.src/integrationTest소스셋에 위치합니다.Summary by CodeRabbit
릴리스 노트
Tests
Chores