Skip to content

[육선우] sprint7#156

Open
ryuk6238-dot wants to merge 48 commits into
codeit-bootcamp-spring:mainfrom
ryuk6238-dot:육선우sprint7

Hidden character warning

The head ref may contain hidden characters: "\uc721\uc120\uc6b0sprint7"
Open

[육선우] sprint7#156
ryuk6238-dot wants to merge 48 commits into
codeit-bootcamp-spring:mainfrom
ryuk6238-dot:육선우sprint7

Conversation

@ryuk6238-dot
Copy link
Copy Markdown
Collaborator

요구사항

기본

  • 기본 항목 1
  • 기본 항목 2

심화

  • 심화 항목 1
  • 심화 항목 2

주요 변경사항

스크린샷

image

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@ryuk6238-dot ryuk6238-dot added the 순한맛🐑 마음이 많이 여립니다.. label Apr 3, 2026
@ryuk6238-dot ryuk6238-dot changed the title 육선우sprint7 [육선우] sprint7 Apr 3, 2026
@eedys1234
Copy link
Copy Markdown
Collaborator

Merge 하려는 브랜치 변경 부탁드려요.

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/binaryContents")
public class BinaryContentController implements BinaryContentApi {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AOP를 활용해서 Reqeust, Response에 대한 로깅을 해보면 어떨까요?!?

datasource:
url: jdbc:postgresql://localhost:5432/discodeit
username: discodeit_user
password: discodeit1234
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

환경 별로 동일한 데이터베이스 계정명이더라도 비밀번호를 다르게 하는것을 권장드려요.
보안적인 측면에서 문제가 발생할 수 있어서요.


jpa:
hibernate:
ddl-auto: update
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

update 보다는 validate를 활용하는 것을 권장드려요.

의도치 않은 동작에 의해 운영중인 데이터베이스 DDL이 변경되어 문제가 발생할 수 있어서요.

예) MySQL 데이터타입과 JAVA 간 데이터타입이 완벽하게 호환이 안되기 때문에 데이터타입 불일치 문제로 오류 발생 가능성

@@ -0,0 +1,60 @@
spring:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

공통되는 부분 별도로 yaml 파일 선언하신 부분 👍👍👍👍

import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;

@SpringBootTest
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

선언하신 4가지 애노테이션을 포함하는 커스텀 애노테이션을 선언해보시면 어떨까요??

@IntegrationTEST 와 같이 선언하여 사용한다면 다른 개발자들이 해당 애노테이션을 봤을 때 어떤 동작을 할 수 있는지 파악가능하며, 재사용 할 수 있는 장점이 있습니다.


@Test
@DisplayName("통합 유저 생성 및 전체 목록 조회 성공")
void user_Integration_Success() throws Exception {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

통합 유저 생성 API, 전체 목록 조회 API 로 분리하여 호출하면 좋을 것 같아요.
또한 하나의 테스트 메서드에 2가지 역할이 부여된 것 같아 나누면 좋을 듯합니다.

통합 유저 생성 테스트
전체 목록 조회 테스트

2번째 전체 목록 조회 테스트는 given 조건에 통합 유저 생성이 필요하기 때문에 2가지 API를 호출하는 방식으로 구현되어야 할 것 같습니다.

// given
통합 유저 생성 API 호출
// when
전체 목록 조회 API 호출
// then
검증

@DataJpaTest
@ActiveProfiles("test")
@EnableJpaAuditing
class UserRepositoryTest {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

보통 현업에서는 JPA가 제공하는 메서드는 테스트코드로 작성하지 않는다는 점 참고 부탁드려요.

저 같은 경우에는 QueryDSL이라는 QueryBuilder 라이브러리를 통해 여러 테이블을 조인하는 쿼리를 작성하는데 해당 쿼리를 검증하기 위한 테스트 코드를 작성합니다.


@Test
@DisplayName("채널 생설 성공")
void createPublicChannelSuccess() throws Exception {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Controller 영역의 테스트는 Request, Response에 대한 필드 검증을 주로 진행하는 점 참고 부탁드려요.

private BasicChannelService channelService;

@Test
@DisplayName("PUBLIC 채널 생성 성공")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mocking은 테스트 코드가 외부 환경에 의존되는 부분을 단절하는 개념에서 많이 사용하는 점 참고 부탁드려요.

여기에서는 데이터베이스라는 외부 환경을 단절합니다.

import com.sprint.mission.discodeit.entity.BinaryContent;
import java.util.Map;

public class BinaryContentException extends DiscodeitException {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Exception을 구분하기 위한 하나의 방안으로 패키지를 세분화하여 Exception을 포함하는 방안이 있습니다.

프로젝트가 커지면 커질수록 너무 많은 Exception들이 존재합니다.

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.

2 participants