Skip to content

fix: OpenAPI 서버 URL 설정 및 Vote 통합 테스트 추가 - #171

Merged
Junhyukkkk merged 4 commits into
developfrom
fix/openapi-config
Jun 3, 2026
Merged

Junhyukkkk merged 4 commits into
developfrom
fix/openapi-config

Conversation

@Junhyukkkk

@Junhyukkkk Junhyukkkk commented May 27, 2026 •

Copy link
Copy Markdown
Member

📌 관련 이슈

  • closes #

🔍 작업 내용

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

    • 투표 생성·상세조회·전체 플로우를 검증하는 통합 테스트 추가로 안정성 강화
    • 투표 저장소의 저장·조회·필터링·상태 판정(진행/종료) 및 옵션 정렬, AI 인사이트 캐시 유지 동작 검증 테스트 추가
  • Chores

    • 운영 환경에서의 API 문서 서버 URL 설정 추가로 OpenAPI 서버 정보 명시화

@Junhyukkkk Junhyukkkk self-assigned this May 27, 2026
@github-actions github-actions Bot added the bug label May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ebba4143-4f50-4824-961f-88376283eaa4

📥 Commits

Reviewing files that changed from the base of the PR and between 51d5276 and 9085856.

📒 Files selected for processing (3)
  • src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java
  • src/integrationTest/java/com/ject/vs/vote/domain/VoteRepositoryIntegrationTest.java
  • src/main/resources/application-prod.yml

Walkthrough

투표 API(생성/상세조회)와 Vote 저장소의 통합 테스트를 추가하고, OpenAPI 구성에서 서버 URL을 프로퍼티 유무에 따라 조건부로 등록하도록 변경합니다.

Changes

Vote Feature Integration Testing

Layer / File(s) Summary
Vote API Integration Tests
src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java
MockMvc 기반으로 /api/votes POST(생성) 및 GET(상세조회) 엔드포인트를 검증합니다. 테스트 인프라(Spring Boot 통합 테스트 설정, 보안 컨텍스트 헬퍼, 테스트 사용자)를 구성하고, 인증된/미인증 요청 처리, 응답 필드(voteId, status, endAt, title), DB 저장 여부(imageUrl 포함 케이스 포함)와 다양한 duration에 대한 종료 시각 계산 및 전체 생성→저장→조회 플로우를 확인합니다.
Vote Repository Integration Tests
src/integrationTest/java/com/ject/vs/vote/domain/VoteRepositoryIntegrationTest.java
@DataJpaTest 환경에서 Vote 및 VoteOption 엔티티의 저장과 필드 매핑(thumbnailUrl, imageUrl, endAt, 생성/수정 시각), 옵션의 position 정렬 결과, 시간 기준 상태 판정(getStatus(Clock)), 진행중/종료 조회 메서드(findOngoingVotes, findExpiredOngoing) 및 cacheAiInsight로 AI 인사이트 캐싱 동작을 고정 Clock으로 검증합니다.

OpenAPI Documentation Configuration

Layer / File(s) Summary
OpenAPI Server URL Configuration
src/main/java/com/ject/vs/config/OpenApiConfig.java, src/main/resources/application-prod.yml
OpenApiConfig에서 springdoc.server-url 프로퍼티를 바인딩하고, 해당 값이 비어있지 않을 때만 OpenAPI 객체에 servers 섹션을 추가하도록 제어 흐름을 변경했습니다. 운영 프로파일에 springdoc.server-url: https://api.vs.io.kr를 추가했습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • JECT-Study/JECT2-4th-Server#172: 투표 API 통합 테스트와 관련된 인증 경로(예: 비인증 허용/제어) 변경과 연관될 수 있습니다.

Suggested reviewers

  • tlarbals824
  • KII1ua

"나는 토끼, 테스트를 깔끔히 심었네
POST와 GET을 뛰어넘어 DB까지 훑었네 🥕
시간은 고정, 상태는 정확히,
옵션 라벨도 줄 맞춰 정렬했네.
문서엔 서버 주소도 달아두었네."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 주요 내용을 명확히 요약하고 있습니다. OpenAPI 서버 URL 설정 수정과 Vote 통합 테스트 추가라는 두 가지 핵심 변경사항을 간결하게 나타냅니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openapi-config

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

빌드 실패
코드를 확인해주세요.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e5c1e5 and 51d5276.

📒 Files selected for processing (4)
  • src/integrationTest/java/com/ject/vs/vote/adapter/web/VoteApiIntegrationTest.java
  • src/integrationTest/java/com/ject/vs/vote/domain/VoteRepositoryIntegrationTest.java
  • src/main/java/com/ject/vs/config/OpenApiConfig.java
  • src/main/resources/application-prod.yml

@Junhyukkkk
Junhyukkkk merged commit 8471a2e into develop Jun 3, 2026
1 check was pending
@Junhyukkkk
Junhyukkkk deleted the fix/openapi-config branch June 3, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant