Skip to content

[test] 최근 포스트 목록 조회 REST Docs 테스트 추가#102

Merged
k3vin7 merged 1 commit intomainfrom
feat/recentPosts
Mar 8, 2026
Merged

[test] 최근 포스트 목록 조회 REST Docs 테스트 추가#102
k3vin7 merged 1 commit intomainfrom
feat/recentPosts

Conversation

@k3vin7
Copy link
Contributor

@k3vin7 k3vin7 commented Mar 8, 2026

Summary

  • GET /posts/recent Swagger 스펙 누락 수정
  • REST Docs 컨트롤러 테스트 추가로 openapi3 스펙에 반영

Test plan

  • PostQueryControllerTest 통과 확인

@k3vin7 k3vin7 merged commit 50911d6 into main Mar 8, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 최근 포스트 목록 조회 API의 문서화를 개선하고 테스트 커버리지를 확장하는 데 중점을 둡니다. 기존에 누락되었던 Swagger 스펙을 보완하고, REST Docs를 활용한 컨트롤러 테스트를 추가하여 API 명세의 정확성과 최신성을 확보합니다. 이를 통해 개발자들이 해당 API를 더 쉽게 이해하고 활용할 수 있도록 돕습니다.

Highlights

  • API 문서화 개선: GET /posts/recent 엔드포인트에 대한 Swagger 스펙 누락이 수정되었습니다.
  • REST Docs 테스트 추가: 최근 포스트 목록 조회 API에 대한 REST Docs 컨트롤러 테스트가 추가되어 OpenAPI 3 스펙에 반영됩니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/test/java/com/daramg/server/post/presentation/PostQueryControllerTest.java
    • 최근 포스트 목록 조회(GET /posts/recent) API에 대한 REST Docs 테스트 케이스를 추가했습니다.
Activity
  • 아직 사람의 활동은 없습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

최근 포스트 목록 조회 API에 대한 REST Docs 테스트를 추가하는 PR입니다. 전반적으로 좋은 변경이지만, 테스트 코드와 생성되는 문서를 개선하기 위한 몇 가지 제안 사항이 있습니다. 첫째, MockMvc 요청에서 GET 메서드에 대해서는 contentType 대신 accept를 사용하는 것이 올바릅니다. 둘째, REST Docs 테스트 데이터에 모든 포스트 타입(FREE, STORY, CURATION)을 포함하여 더 완전한 응답 필드 문서를 생성하는 것이 좋습니다. 자세한 내용은 각 리뷰 코멘트를 참고해주세요.

Comment on lines +752 to +773
PostResponseDto recentPost = new PostResponseDto(
1L,
"최근 포스트 제목",
"최근 포스트 내용입니다",
List.of("#해시태그1"),
Instant.parse("2024-01-15T10:30:00Z"),
"작성자1",
10,
5,
"https://example.com/image1.jpg",
PostType.FREE,
null,
null,
null,
null
);

PageResponseDto<PostResponseDto> response = new PageResponseDto<>(
List.of(recentPost),
null,
false
);

Choose a reason for hiding this comment

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

medium

현재 테스트는 FREE 타입의 포스트만 포함하고 있어, STORYCURATION 타입 포스트에만 존재하는 primaryComposer, additionalComposers 필드에 대한 문서가 불완전하게 생성됩니다. REST Docs 문서의 완성도를 높이기 위해, 다양한 포스트 타입을 포함하는 테스트 데이터를 생성하여 응답에 포함시키는 것을 권장합니다. 이렇게 하면 API 사용자가 각 포스트 타입에 따른 응답 구조를 더 명확하게 이해할 수 있습니다.

예를 들어, 다음과 같이 다양한 타입의 포스트를 생성할 수 있습니다:

// given
var composerSummary = new PostResponseDto.ComposerSummary(1L, "바흐", com.daramg.server.composer.domain.Era.BAROQUE, com.daramg.server.composer.domain.Continent.EUROPE);
var anotherComposer = new PostResponseDto.ComposerSummary(2L, "모차르트", com.daramg.server.composer.domain.Era.CLASSICAL, com.daramg.server.composer.domain.Continent.EUROPE);

PostResponseDto freePost = new PostResponseDto(
        1L, "최근 포스트 제목 (FREE)", "자유 포스트 내용입니다.", List.of("#자유"),
        Instant.parse("2024-01-15T10:30:00Z"), "작성자1", 10, 5,
        "https://example.com/image1.jpg", PostType.FREE, null, null, true, false
);

PostResponseDto storyPost = new PostResponseDto(
        2L, "최근 포스트 제목 (STORY)", "스토리 포스트 내용입니다.", List.of("#스토리", "#바흐"),
        Instant.parse("2024-01-14T11:00:00Z"), "작성자2", 20, 8,
        "https://example.com/image2.jpg", PostType.STORY, composerSummary, null, false, true
);

PostResponseDto curationPost = new PostResponseDto(
        3L, "최근 포스트 제목 (CURATION)", "큐레이션 포스트 내용입니다.", List.of("#큐레이션", "#클래식"),
        Instant.parse("2024-01-13T12:00:00Z"), "작성자3", 30, 15,
        "https://example.com/image3.jpg", PostType.CURATION, composerSummary, List.of(anotherComposer), true, true
);

PageResponseDto<PostResponseDto> response = new PageResponseDto<>(
        List.of(freePost, storyPost, curationPost),
        "bmV4dEN1cnNvcg==", // Base64 encoded cursor
        true
);

이렇게 하면 primaryComposer, additionalComposers, nextCursor 필드가 포함된 응답 예시가 문서에 생성됩니다.

// when
ResultActions result = mockMvc.perform(get("/posts/recent")
.param("size", "10")
.contentType(MediaType.APPLICATION_JSON)

Choose a reason for hiding this comment

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

medium

GET 요청에서는 요청 본문이 없으므로 contentType을 설정하는 것은 의미가 없습니다. 클라이언트가 수신하고자 하는 미디어 타입을 지정하려면 accept(MediaType.APPLICATION_JSON)를 사용해야 합니다.

Suggested change
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant