Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: #19 스터디 목록 조회 API 수정 #20

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

msjang4
Copy link
Contributor

@msjang4 msjang4 commented Jun 17, 2024

작업 개요

  1. 프론트에서 페이지네이션 바 구현 시 필요한 추가 정보 반환
    • 현재 페이지 번호, 총 요소 개수, 총 페이지 수
  2. snake_case 응답에서 camelCase로 변경
  3. 관련 테스트 코드 수정

관련 이슈

closed: #19

작업 사항

기존 API 응답

[
    {
          "id": 1,
          "name": "Spring으로 Spring만들기",
          "introduce": "재밌어요 같이해요",
          "capacity": 0,
          "weeks": 5,
          "penalty": 5000,
          "state": "READY",
          "head_count": 0,
          "start_date": "2024-06-15",
          "reliability_limit": 36,
          "study_type": "BOOK",
          "book_id": 129
    }, ...
]

수정된 API 응답

{
    "totalElements": 32,
    "totalPages": 4,
    "pageNumber": 0,
    "contents": [
        {
            "id": 32,
            "name": "Multi-layered content-based function",
            "introduce": "Fuga laboriosam nihil ducimus nam. Repudiandae maxime id deserunt quae. Quaerat nihil quidem. Aut voluptas incidunt itaque nostrum optio. Aut ipsam autem nesciunt minima tenetur. Molestiae earum quis saepe quam molestiae.",
            "capacity": 4,
            "headCount": 1,
            "weeks": 17,
            "startDate": "2024-07-31",
            "reliabilityLimit": 48,
            "penalty": 15000,
            "state": "READY",
            "studyType": "BOOK",
            "bookId": 651
        }, ...
    ]
}

@msjang4 msjang4 added ✨Feat 새로운 기능 추가 ✅Test 테스트 추가 / 수정 labels Jun 17, 2024
@msjang4 msjang4 added this to the sprint #2 (06.17 ~ 06.23) milestone Jun 17, 2024
@msjang4 msjang4 requested review from sseunghoon and platinouss June 17, 2024 14:46
@msjang4 msjang4 self-assigned this Jun 17, 2024
@msjang4 msjang4 changed the title Feat: 스터디 목록 조회 API 수정 Feat: #19 스터디 목록 조회 API 수정 Jun 17, 2024
Copy link
Contributor

@platinouss platinouss left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ~~

Copy link
Contributor

@sseunghoon sseunghoon left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍

@@ -40,8 +41,8 @@ class StudyControllerTest {
private ObjectMapper objectMapper;

@Test
@DisplayName("스터디 컨트롤러의 studyList 메소드는 StudyResponse의 JSON Array룰 반환한다 ")
void study_controller_study_list_return_json_array_of_study_response() throws Exception {
@DisplayName("스터디 컨트롤러의 studyList 메소드는 StudyPageResponse룰 반환한다 ")
Copy link
Contributor

Choose a reason for hiding this comment

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

유저는 존재하는 스터디를 최신순으로 10개씩 페이지별로 조회할 수 있다.
이런 식으로 서비스를 설명하는 명제로 테스트를 짓는게 좋을 것 같습니다

다른 사람 혹은 나중에 프로젝트에 투입된 사람도 무엇을 테스트하는지 쉽게 파악이 가능하고
테스트만 보고도 해당 프로젝트에 어떤 기능과 정책들이 있는지 파악할 수 있도록
(코드로 대화할 수 있도록) 테스트를 작성하는게 이상적이라고 생각합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DisplayName을 테스트하는 기능에 대해 최대한 잘 설명하는게 좋다고 저도 생각하기에 지금 명칭이 최선인 것 같진 않아요.

다만 단위테스트에서는 서비스가 아닌 모듈 하나의 동작을 테스트하는 거라 서비스에 대한 명제로 테스트를 명명하는 게 맞는 지 잘 모르겠습니다.
만약 테스트 명칭을 서비스에 대한 설명으로 짓게 된다면 하나의 서비스 기능과 관련된 컨트롤러 단위테스트, 서비스 단위테스트, 통합테스트 등 여러 테스트 명칭이 동일하게 될 것 같습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

컨트롤러 테스트가 통합 테스트가 된다고 생각하고 있었는데 그럼 혹시 통합 테스트는 어떤식으로 진행될까요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.pageNumber(0)
.contents(serviceResponse)
.build();
when(studyService.readStudy(any(Pageable.class))).thenReturn(studyPageResponse);
Copy link
Contributor

Choose a reason for hiding this comment

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

이런식으로 Service를 모킹하면 테스트를 작성하는 의미가 떨어진다고 생각합니다.
실제로는 서비스가 틀린 응답값을 주고 있더라도 파악이 되지 않아요!
실제 MySQL을 구동하는 방식으로 테스트를 하는게 좋을 것 같습니다.

Copy link
Contributor Author

@msjang4 msjang4 Jun 18, 2024

Choose a reason for hiding this comment

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

상위 모듈(컨트롤러)의 단위테스트에서 종속 모듈(서비스)가 잘 작동하는 지 고려해야 한다는게 이해가 되지 않습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

위 대화가 해결 되면 자연스럽게 해결될 거 같습니다.

Copy link
Contributor

@sseunghoon sseunghoon left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍

@msjang4 msjang4 merged commit c7b93da into develop Jun 18, 2024
1 check passed
@msjang4 msjang4 deleted the feat/19-modifiy_study_list branch June 18, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨Feat 새로운 기능 추가 ✅Test 테스트 추가 / 수정
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Feat: 스터디 목록 조회 API 수정
3 participants