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] 주제, 선택지 조회 기능 구현 #36

Merged
merged 23 commits into from
Jul 22, 2024
Merged

[FEAT] 주제, 선택지 조회 기능 구현 #36

merged 23 commits into from
Jul 22, 2024

Conversation

leegwichan
Copy link
Member

Issue Number

#28

As-Is

방에 진행 중인(가장 최신의) 주제, 선택지 조회 기능 필요

To-Be

방에 진행 중인(가장 최신의) 주제, 선택지 조회 기능 구현

Check List

  • 테스트가 전부 통과되었나요?
  • 모든 commit이 push 되었나요?
  • merge할 branch를 확인했나요?
  • Assignee를 지정했나요?
  • Label을 지정했나요?

Test Screenshot

image

(Optional) Additional Description

@leegwichan leegwichan added ✨ feat 기능 추가 🍃 BE back end labels Jul 19, 2024
@leegwichan leegwichan self-assigned this Jul 19, 2024
@leegwichan leegwichan changed the title [FEAT] 주제, 선택지 조회 디능 구현 [FEAT] 주제, 선택지 조회 기능 구현 Jul 19, 2024
@leegwichan
Copy link
Member Author

리뷰 중점 사항

  • 컨벤션이 잘 지켜졌나요?
  • 추후 리팩토링 해야 할 사항은 무엇이 있을까요?
    • Exception 관리 방법, 패키지 구조 관리, AuditingEntity, ...
    • BaseXXXTest 관리, 테스트 데이터 관리, ...

@leegwichan
Copy link
Member Author

application-local.yml

spring:
  h2:
    console:
      enabled: true
      path: /h2-console
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:db;MODE=MYSQL
    username: sa
    password:
  jpa:
    generate-ddl: 'true'
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        show_sql: true
        format_sql: true
        highlight_sql: true
        use_sql_comments: true
    database-platform: org.hibernate.dialect.H2Dialect

logging:
  level:
    org:
      hibernate:
        orm:
          jdbc:
            bind: TRACE
      springframework:
        transaction:
          interceptor: TRACE

@leegwichan
Copy link
Member Author

leegwichan commented Jul 20, 2024

TODO List

  • 도메인

    • AuditingEntity → BaseEntity로 이름 변경
    • repository를 도메인 패키지 안으로 이동
    • Repository 애노테이션 제거
    • Lazy Loading을 했으므로 @ToString, @EqualsAndHashCode 제거
  • exception handler

    • violateDataException → log.error로 변경
    • exception을 아키텍쳐 별로 두도록 변경
  • 테스트

    • RestAssured 5.3.1로 명시되어 있는데, latest version인지 확인
    • @SQL → executionPhase default 값 제거
    • BaseServiceTest → RandomPort 빼기
    • init-test.sql → insert query 하나로
    • 테스트 케이스에서 ‘똥’ 빼주세요. 더러워요.

    참고 문서 : https://www.notion.so/ghenmaru/be52b0047aa0416886b77f76199db2f0

jhon3242
jhon3242 previously approved these changes Jul 20, 2024
Copy link
Member

@jhon3242 jhon3242 left a comment

Choose a reason for hiding this comment

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

코드리뷰 빠르게 반영한 커찬 칭찬해~

GIVEN53
GIVEN53 previously approved these changes Jul 20, 2024
Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

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

빠른 반영 👍🏼
어제 논의했던 클래스명, 필드명 수정도 반영해주시면 감사하겠습니다!
이에 따라 dto 필드명도 몇 가지 수정이 생길 것 같아요 함께 확인 부탁드려요

approve 하겠습니당

- BalanceQuestion -> BalanceContent로 변경
- 필드명 content, title 등을 name으로 바꿈
@leegwichan leegwichan dismissed stale reviews from GIVEN53 and jhon3242 via 06b3dba July 20, 2024 15:59
@leegwichan
Copy link
Member Author

변경 사항

  • 구분하기 쉽게 Table, Column 명 변경

    • 회의 결과에 따라 변경함
  • 테이블 명, 필드 명 변경 사항

    • BalanceQuestion -> BalanceContent
      • content -> name
    • BalanceOption
      • content -> name
    • RoomQuestion -> RoomContent
  • 이와 관련된 Service, Repository 이름도 변경

    • BalanceQuestionService -> BalanceContentService, ...

기타 사항

  • 작업 관련

    • 자질구레한 변경이나, 오타로서 놓친 부분은 바로 반영하도록 하겠습니다. 피드백 부탁드립니다~
    • 추가적인 내용의 변경사항은 REFACTOR, FIX 형태로 새로 브랜치 타서 작업하겠습니다~ (PR단위가 계속 커지는 느낌이 들어서;;)
  • API 명세 관련

    • Table, Column 이름은 바꾸었는데, API 명세는 그대로입니다.
    • 일단 BE 논의 짬통에 넣어두었습니다~!

Copy link
Member

@jhon3242 jhon3242 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
Member

@PgmJun PgmJun left a comment

Choose a reason for hiding this comment

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

커찬 고생하셨숩니다! 질문이나 의견 남겨두었는데 확인 부탁드려요!

Comment on lines 19 to 20
@ExceptionHandler
public ErrorResponse handleBindingException(BindException e) {
Copy link
Member

Choose a reason for hiding this comment

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

의견) 여기 ResponseStatus가 안되어 있는 것 같네요! 확인 부탁드려요!

@@ -0,0 +1,27 @@
package ddangkong.controller.content.dto;
Copy link
Member

Choose a reason for hiding this comment

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

의견) BalanceOption, BalanceContent 라는 도메인 네이밍이지만 패키지는 그냥 content 인 것이 괜찮을 지 고민이 되네요
저희가 밸런스 게임 제공 서비스가 아니라 대화주제 제공 서비스이며, 밸런스 게임은 그 중 하나의 도메인일 뿐이니 이런식으로 두는 건 어떨까에 대해 같이 고민해보면 좋을 것 같아요!
depth가 깊어지지만 알아보기는 더 쉬울 것 같기도 합니다:)

controller/
                    │   ├── balance/
                    │   │   ├── option/
                    │   │   │   └── BalanceOptionController.java
                    │   │   └── question/
                    │   │       └── BalanceQuestionController.java

Copy link
Member Author

Choose a reason for hiding this comment

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

7/22 회의 결과, balance package 추가하도록 하겠습니다~

Comment on lines 15 to 18
private static final BalanceContentResponse EXPECTED_RESPONSE = new BalanceContentResponse(
1L, Category.EXAMPLE, "민초 vs 반민초",
new BalanceOptionResponse(1L, "민초"),
new BalanceOptionResponse(2L, "반민초"));
Copy link
Member

Choose a reason for hiding this comment

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

의견) 특정 기능에서 필요한 클래스 변수는 Nested Class 내부에 넣어두는 것이 어떨까요?

new BalanceOptionResponse(2L, "반민초"));

@Nested
class 방의_질문_조회 {
Copy link
Member

Choose a reason for hiding this comment

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

사소한 의견) 기능에 대한 설명을 명확히 하기위해 방의_현재_질문_조회 로 변경하는 것은 어떨까요?

Comment on lines 20 to 24
void 방의_가장_최신의_질문을_조회할_수_있다() {
RoomContent actual = roomContentRepository.findTopByRoomIdOrderByCreatedAtDesc(1L).get();

assertThat(actual.getId()).isEqualTo(2L);
}
Copy link
Member

Choose a reason for hiding this comment

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

사소한 의견) Service 로직에 given, when, then 을 사용해서 테스트에 대한 이해도를 높여주면 어떨까 싶습니다~!
테스트 코드는 기능에 대한 문서라고 생각하기 잘 정의해두면 좋을 것 같아서 때문에 제안드려봤어요!

Comment on lines 23 to 33
@Test
void 현재_방의_질문을_조회할_수_있다() {
BalanceContentResponse actual = RestAssured.given().log().all()
.when().get("/api/balances/rooms/1/question")
.then().log().all()
.statusCode(200)
.extract().as(BalanceContentResponse.class);

assertThat(actual).isEqualTo(EXPECTED_RESPONSE);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

의견) 방에 질문이 없다면 예외를 발생시키거나, 방이 존재하지 않으면 예외를 발생시키는 부분도 같이 테스트해주면 좋을 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

컨트롤러 레이어에서는 해피케이스, Request와 관련된 내용만 테스트하고 나머지 예외 상황은 서비스 레이어에서 테스트 했습니다.

현 상황에서 컨트롤러는 서비스가 예외를 일으키는지 알 수 없으니까, 예외와 관련된 테스트는 서비스 레이어만으로 충분하다고 생각합니다. 만약 예외 상황에 대한 테스트가 필요하다고 생각된다면, GlobalExceptionHandlerTest를 만들도록 하겠습니다~

@leegwichan
Copy link
Member Author

leegwichan commented Jul 22, 2024

TODO

  • 비즈니스 코드
    • RoomContentRepositoryRoomContent와 동일한 패키지로 변경
    • 서버 에러 시, 에러 스택 트레이스까지 출력하도록 변경 (error 상황 한정)
    • GlobalExceptionHandler에서 누락된 @ResponseStatus 추가
    • 각 계층별로 balance package 추가 (domain.content -> domain.balance.content)
    • 변경된 API 적용 (일부 json key 값)
    • Validation 적용 (@Positive)
  • 테스트 코드
    • 특정 기능에서 필요한 클래스 변수는 Nested Class 내부로 이동
    • 방의_질문_조회에서 방의_현재_질문_조회로 변경
    • given, when, then 주석 추가

GIVEN53
GIVEN53 previously approved these changes Jul 22, 2024
Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

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

LGTM 🤗🤗

PgmJun
PgmJun previously approved these changes Jul 22, 2024
Copy link
Member

@PgmJun PgmJun left a comment

Choose a reason for hiding this comment

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

LGTM🔥
네이밍관련 사소한 의견 한 가지 남겨두었으니 확인부탁드려요!

private BalanceContentService balanceContentService;

@Nested
class 현재_방의_내용_조회 {
Copy link
Member

Choose a reason for hiding this comment

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

사소한 의견) 방의 내용이라기 보단, 현재_방의_밸런스_게임_내용_조회가 BalanceContent라는 도메인에 적합한 테스트 클래스명이지 않을까 싶습니다:)

jhon3242
jhon3242 previously approved these changes Jul 22, 2024
Copy link
Member

@jhon3242 jhon3242 left a comment

Choose a reason for hiding this comment

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

커칭커칭~

테스트가 어떤 도메인인지 드러나도록 변경
@leegwichan leegwichan dismissed stale reviews from jhon3242, PgmJun, and GIVEN53 via 2cc2472 July 22, 2024 14:32
@GIVEN53 GIVEN53 merged commit 3041d4a into develop Jul 22, 2024
1 check passed
@leegwichan leegwichan deleted the feat/#28 branch December 9, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍃 BE back end ✨ feat 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants