Skip to content

[강현홍] sprint7#157

Open
Newbress wants to merge 17 commits into
codeit-bootcamp-spring:mainfrom
Newbress:hyunhong-sprint7
Open

[강현홍] sprint7#157
Newbress wants to merge 17 commits into
codeit-bootcamp-spring:mainfrom
Newbress:hyunhong-sprint7

Conversation

@Newbress
Copy link
Copy Markdown
Collaborator

@Newbress Newbress commented Apr 4, 2026

요구사항

기본

  • Profile 기반 설정 관리: dev, prod, test 환경 분리 및 데이터베이스 설정 차별화
  • Logging 관리: Slf4j와 Logback을 활용한 파일 롤링 및 레벨 제어
  • Exception Handling 고도화: DiscodeitException 계층화 및 ErrorCode 도입
  • Validation: Request DTO 제약 조건 설정 및 전역 예외 처리
  • Actuator: health, info, metrics 등 엔드포인트 활성화 및 애플리케이션 정보 추가
  • Test Code: Service, Repository, Controller 계층별 테스트 구현

심화

  • MDC 로깅: requestId 추적 인터셉터 구현 및 로그 패턴 반영
  • Spring Boot Admin: 별도 모듈 구축을 통한 실시간 모니터링 가시화
  • Test Coverage: JaCoCo 적용 및 Service Layer 커버리지 60% 이상 달성

주요 변경사항

스크린샷

image

멘토에게

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

@Newbress Newbress requested a review from eedys1234 April 4, 2026 18:53
@eedys1234
Copy link
Copy Markdown
Collaborator

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

@eedys1234
Copy link
Copy Markdown
Collaborator

.gitignore 파일에 .log* 추가해서 원격저장소에 올라가지 않도록 권장드려요.

max-file-size: ${spring.servlet.multipart.max-file-size}
max-request-size: ${spring.servlet.multipart.max-request-size}

management:
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.

👍👍👍

</encoder>
</appender>

<root level="info">
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.

환경별로 로그를 기록하는 걸 분리해보는걸 권장드려요.

import jakarta.validation.constraints.NotNull;

public record BinaryContentCreateRequest(
@NotNull
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.

String 타입은 @NotNull 보다는 @notblank를 권장드려요.
@NotNull은 말그대로 null을 허용하지 않겠다는 의미로 "", " "은 허용됩니다.

import com.sprint.mission.discodeit.exception.ErrorCode;
import java.util.Map;

public abstract class UserStatusException 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들을 세밀하게 에러처리 가능한 장점이 있습니다.

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/binaryContents")
public class BinaryContentController {
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를 활용하여 Controller 모든 메서드의 Request, Response 로깅을 한번 해보시는걸 추천드려요.

"userCreateRequest", "", MediaType.APPLICATION_JSON_VALUE, invalidJson.getBytes()
);

MockMultipartFile profile = new MockMultipartFile(
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.

👍👍👍

@Test
@DisplayName("퍼블릭 채널 생성 통합 테스트 - 성공 (실제 DB 저장 확인)")
void createPublicChannel_Integration_Success() throws Exception {
String requestJson = "{\"name\":\"통합테스트채널\", \"description\":\"통합 테스트용 퍼블릭 채널\"}";
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.

JSON 형태의 String 을 전달하기 보다는 실제 활용되는 Request 객체를 생성하여 ObjectMapper를 통해 JSON으로 직렬화하는 방법을 권장드려요.

@Test
@DisplayName("채널 정보 수정 통합 테스트 - 성공 (실제 DB 변경 확인)")
void updateChannel_Integration_Success() throws Exception {
Channel channel = new Channel(ChannelType.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.

위 케이스의 통합테스트는 Repository를 통해 채널 정보를 저장하기 보다는 채널을 생성 API 호출, 채널 정보를 수정하는 API 호출, 채널 정보가 수정되었는지 조회하는 API 호출하는 방법으로 진행하면 좋을 것 같아요.

  • given 영역에는 채널 생성 API 호출
  • when 영역에는 채널 정보 수정 API 호출
  • then 영역에는 채널 정보 조회 API 호출 후 검증

@Newbress Newbress changed the title Hyunhong sprint7 [강현홍] sprint7 Apr 9, 2026
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.

2 participants