Skip to content

[강호] sprint7 #191

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

Open
wants to merge 10 commits into
base: 강호
Choose a base branch
from

Conversation

kangho1870
Copy link
Collaborator

기본 요구사항

프로파일 기반 설정 관리

  • 개발, 운영 환경에 대한 프로파일을 구성하세요.
    • application-dev.yaml, application-prod.yaml 파일을 생성하세요.
    • 다음과 같은 설정값을 프로파일별로 분리하세요.
      • 데이터베이스 연결 정보
      • 서버 포트

로그 관리

  • Lombok의 @slf4j 어노테이션을 활용해 로깅을 쉽게 추가할 수 있도록 구성하세요.

  • application.yaml에 기본 로깅 레벨을 설정하세요.

    • 기본적으로 info 레벨로 설정합니다.
  • 환경 별 적절한 로깅 레벨을 프로파일 별로 설정해보세요.

    • SQL 로그를 보기위해 설정했던 레벨은 유지합니다.
    • 우리가 작성한 프로젝트의 로그는 개발 환경에서 debug, 운영 환경에서는 info 레벨로 설정합니다.
  • Spring Boot의 기본 로깅 구현체인 Logback의 설정 파일을 구성하세요.

    • logback-spring.xml 파일을 생성하세요.
    • 다음 예시와 같은 로그 메시지를 출력하기 위한 로깅 패턴과 출력 방식을 커스터마이징하세요.
      • 로그 출력 예시
        # 패턴
        {년}-{월}-{일} {시}:{분}:{초}:{밀리초} [{스레드명}] {로그 레벨(5글자로 맞춤)} {로거 이름(최대 36글자)} - {로그 메시지}{줄바꿈}
        
        # 예시
        25-01-01 10:33:55.740 [main] DEBUG c.s.m.discodeit.DiscodeitApplication - Running with Spring Boot v3.4.0, Spring v6.2.0
      
    • 콘솔과 파일에 동시에 로그를 기록하도록 설정하세요.
      • 파일은 {프로젝트 루트}/.logs 경로에 저장되도록 설정하세요.
    • 로그 파일은 일자별로 롤링되도록 구성하세요.
    • 로그 파일은 30일간 보관하도록 구성하세요.
  • 서비스 레이어와 컨트롤러 레이어의 주요 메소드에 로깅을 추가하세요.

    • 로깅 레벨을 적절히 사용하세요: ERROR, WARN, INFO, DEBUG
    • 다음과 같은 메소드에 로깅을 추가하세요:
      • 사용자 생성/수정/삭제
      • 채널 생성/수정/삭제
      • 메시지 생성/수정/삭제
      • 파일 업로드/다운로드

예외 처리 고도화

  • 커스텀 예외를 설계하고 구현하세요.
    • 패키지명: com.sprint.mission.discodeit.exception[.{도메인}]
    • ErrorCode Enum 클래스를 통해 예외 코드명과 메시지를 정의하세요.
      • 아래는 예시입니다. 필요하다고 판단되는 다양한 코드를 정의하세요.
      • 예시
        image
    • 모든 예외의 기본이 되는 DiscodeitException 클래스를 정의하세요.
      • 클래스 다이어그램
        image

      • details는 예외 발생 상황에 대한 추가정보를 저장하기 위한 속성입니다.

        • 예시
          • 조회 시도한 사용자의 ID 정보
          • 업데이트 시도한 PRIVATE 채널의 ID 정보
    • DiscodeitException을 상속하는 주요 도메인 별 메인 예외 클래스를 정의하세요.
      • UserException, ChannelException 등
      • 실제로 활용되는 클래스라기보다는 예외 클래스의 계층 구조를 명확하게 하기 위한 클래스 입니다.
    • 도메인 메인 예외 클래스를 상속하는 구체적인 예외 클래스를 정의하세요.
      • UserNotFoundException, UserAlreadyExistException 등 필요한 예외를 정의하세요.
      • 예시
        image
  • 기존에 구현했던 예외를 커스텀 예외로 대체하세요.
    • NoSuchElementException
    • IllegalArgumentException
  • ErrorResponse를 통해 일관된 예외 응답을 정의하세요.
    • 클래스 다이어그램
      image
    • int status: HTTP 상태코드
    • String exceptionType: 발생한 예외의 클래스 이름
  • 앞서 정의한 ErrorResponse와 @RestControllerAdvice를 활용해 예외를 처리하는 예외 핸들러를 구현하세요.
    • 모든 핸들러는 일관된 응답(ErrorResponse)을 가져야 합니다.

유효성 검사

  • Spring Validation 의존성을 추가하세요.
  • 주요 Request DTO에 제약 조건 관련 어노테이션을 추구하세요.
    • @NotNull, @NotBlank, @Size, @Email
  • 컨트롤러에 @Valid 를 사용해 요청 데이터를 검증하세요.
  • 검증 실패 시 발생하는 MethodArgumentNotValidException을 전역 예외 핸들러에서 처리하세요.
  • 유효성 검증 실패 시 상세한 오류 메시지를 포함한 응답을 반환하세요.

Actuator

  • Spring Boot Actuator 의존성을 추가하세요.
  • 기본 Actuator 엔트포인트를 설정하세요.
    • health, info, metrics, loggers
  • Actuator info를 위한 애플리케이션 정보를 추가하세요.
    • 애플리케이션 이름: Discodeit
    • 애플리케이션 버전: 1.7.0
    • 자바 버전: 17
    • 스프링 부트 버전: 3.4.0
    • 주요 설정 정보
      • 데이터소스: url, 드라이버 클래스 이름
      • jpa: ddl-auto
      • storage 설정: type, path
      • multipart 설정: max-file-size, max-request-size
  • Spring Boot 서버를 실행 후 각종 정보를 확인해보세요.
    • /actuator/info
    • /actuator/metrics
    • /actuator/health
    • /actuator/loggers

단위 테스트

  • 서비스 레이어의 주요 메소드에 대한 단위 테스트를 작성하세요.
    • 다음 서비스의 핵심 메소드에 대해 각각 최소 2개 이상(성공, 실패)의 테스트 케이스를 작성하세요.
      • UserService: create, update, delete 메소드
      • ChannelService: create(PUBLIC, PRIVATE), update, delete, findByUserId 메소드
      • MessageService: create, update, delete, findByChannelId 메소드
    • Mockito를 활용해 Repository 의존성을 모의(mock)하세요.
    • BDDMockito를 활용해 테스트 가독성을 높이세요.

슬라이스 테스트

  • 레포지토리 레이어의 슬라이스 테스트를 작성하세요.
    • @DataJpaTest를 활용해 테스트를 구현하세요.
    • 테스트 환경을 구성하는 프로파일을 구성하세요.
      • application-test.yaml을 생성하세요.
      • 데이터소스는 H2 인메모리 데이터 베이스를 사용하고, PostgreSQL 호환 모드로 설정하세요.
      • H2 데이터베이스를 위해 필요한 의존성을 추가하세요.
      • 테스트 시작 시 스키마를 새로 생성하도록 설정하세요.
      • 디버깅에 용이하도록 로그 레벨을 적절히 설정하세요.
    • 테스트 실행 간 test 프로파일을 활성화 하세요.
    • JPA Audit 기능을 활성화 하기 위해 테스트 클래스에 @EnableJpaAuditing을 추가하세요.
    • 주요 레포지토리(User, Channel, Message)의 주요 쿼리 메소드에 대해 각각 최소 2개 이상(성공, 실패)의 테스트 케이스를 작성하세요.
      • 커스텀 쿼리 메소드
      • 페이징 및 정렬 메소드
  • 컨트롤러 레이어의 슬라이스 테스트를 작성하세요.
    • @WebMvcTest를 활용해 테스트를 구현하세요.
    • WebMvcTest에서 자동으로 등록되지 않는 유형의 Bean이 필요하다면 @import를 활용해 추가하세요.
      • 예시
      @Import({ErrorCodeStatusMapper.class})
      
    • 주요 컨트롤러(User, Channel, Message)에 대해 최소 2개 이상(성공, 실패)의 테스트 케이스를 작성하세요.
    • MockMvc를 활용해 컨트롤러를 테스트하세요.
    • 서비스 레이어를 모의(mock)하여 컨트롤러 로직만 테스트하세요.
    • JSON 응답을 검증하는 테스트를 포함하세요.

통합 테스트

  • 통합 테스트 환경을 구성하세요.
    • @SpringBootTest를 활용해 Spring 애플리케이션 컨텍스트를 로드하세요.
    • H2 인메모리 데이터베이스를 활용하세요.
    • 테스트용 프로파일을 구성하세요.
  • 주요 API 엔드포인트에 대한 통합 테스트를 작성하세요.
    • 주요 API에 대해 최소 2개 이상의 테스트 케이스를 작성하세요.
      • 사용자 관련 API (생성, 수정, 삭제, 목록 조회)
      • 채널 관련 API (생성, 수정, 삭제)
      • 메시지 관련 API (생성, 수정, 삭제, 목록 조회)
    • 각 테스트는 @transactional을 활용해 독립적으로 실행하세요.

심화 요구사항

MDC를 활용한 로깅 고도화

  • 요청 ID, 요청 URL, 요청 방식 등의 정보를 MDC에 추가하는 인터셉터를 구현하세요.
    • 클래스명: MDCLoggingInterceptor
    • 패키지명: com.**.discodeit.config
    • 요청 ID는 랜덤한 문자열로 생성합니다. (UUID)
    • 요청 ID는 응답 헤더에 포함시켜 더 많은 분석이 가능하도록 합니다.
      • 헤더 이름: Discodeit-Request-ID
  • WebMvcConfigurer를 통해 MDCLoggingInterceptor를 등록하세요.
    • 클래스명: WebMvcConfig
    • 패키지명: com.**.discodeit.config
  • Logback 패턴에 MDC 값을 포함시키세요.
    • 로그 출력 예시
     # 패턴
     {년}-{월}-{일} {시}:{분}:{초}:{밀리초} [{스레드명}] {로그 레벨(5글자로 맞춤)} {로거 이름(최대 36글자)} [{MDC:요청ID} | {MDC:요청 메소드} | {MDC:요청 URL}] - {로그 메시지}{줄바꿈}
     
     # 예시
     25-01-01 10:33:55.740 [main] DEBUG o.s.api.AbstractOpenApiResource [827cbc0b | GET | /v3/api-docs] - Init duration for springdoc-openapi is: 216 ms
    

Spring Boot Admin을 활용한 메트릭 가시화

  • Spring Boot Admin 서버를 구현할 모듈을 생성하세요.
    • IntelliJ 화면 참고
      image
    • 모듈 정보는 다음과 같습니다.
      image
    • 의존성
      image
  • admin 모듈의 메인 클래스에 @EnableAdminServer 어노테이션을 추가하고, 서버는 9090번 포트로 설정합니다.
import de.codecentric.boot.admin.server.config.EnableAdminServer;

@SpringBootApplication
@EnableAdminServer
public class AdminApplication {
    public static void main(String[] args) {
        SpringApplication.run(AdminApplication.class, args);
    }
}
# application.yaml
spring:
    application:
        name: admin
server:
    port: 9090
  • admin 서버 실행 후 localhost:9090/applications 에 접속해봅니다.
  • discodeit 프로젝트에 Spring Boot Admin Client를 적용합니다.
    • 의존성을 추가합니다.
     dependencies {
         ...
         implementation 'de.codecentric:spring-boot-admin-starter-client:3.4.5
     }
    
    • admin 서버에 등록될 수 있도록 설정 정보를 추가합니다.
     # application.yml
     spring:
       application:
         name: discodeit
         ...
       boot:
         admin:
           client:
             instance:
               name: discodeit
     ...
    
     # application-dev.yml
     spring:
       application:
         name: discodeit
         ...
       boot:
         admin:
           client:
             url: http://localhost:9090
     ...
    
     # application-prod.yml
     spring:
       application:
         name: discodeit
         ...
       boot:
         admin:
           client:
             url: ${SPRING_BOOT_ADMIN_CLIENT_URL}
     ...
    
    • discodeit 서버를 실행하고, admin 대시보드에 discodeit 인스턴스가 추가되었는지 확인합니다.
  • admin 대시보드 화면을 조작해보면서 각종 메트릭 정보를 확인해보세요.
    • 주요 API의 요청 횟수, 응답시간 등
    • 서비스 정보

테스트 커버리지 관리

  • JaCoCo 플러그인을 추가하세요.
  plugins {
      id 'jacoco'
  }
  
  test {
      finalizedBy jacocoTestReport
  }
  
  jacocoTestReport {
      dependsOn test
      reports {
          xml.required = true
          html.required = true
      }
  }
  • 테스트 실행 후 생성된 리포트를 분석해보세요.
    • 리포트는 build/reports/jacoco 경로에서 확인할 수 있습니다.
  • com.sprint.mission.discodeit.service.basic 패키지에 대해서 60% 이상의 코드 커버리지를 달성하세요.

스크린샷

image
image

@kangho1870 kangho1870 requested a review from dongjoon1251 June 23, 2025 02:14
@kangho1870 kangho1870 added the 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. label Jun 23, 2025
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAdminServer
Copy link
Collaborator

Choose a reason for hiding this comment

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

admin 서버 구성 👍

Comment on lines +22 to +29
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

jacoco 적용 👍

build.gradle Outdated
@@ -13,6 +14,19 @@ java {
}
}

test {
finalizedBy jacocoTestReport
// jvmArgs "-Duser.timezone=UTC"
Copy link
Collaborator

Choose a reason for hiding this comment

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

사용되지 않는 코드는 과감히 삭제해주세요!

Comment on lines 17 to 27
@Pointcut("execution(* com.sprint.mission.discodeit.service.basic.BasicUserService.create*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicUserService.update*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicUserService.delete*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicChannelService.create*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicChannelService.update*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicChannelService.delete*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicMessageService.create*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicMessageService.update*(..)) || " +
"execution(* com.sprint.mission.discodeit.service.basic.BasicMessageService.delete*(..)) || " +
"execution(* com.sprint.mission.discodeit.storage.LocalBinaryContentStorage.put*(..)) || " +
"execution(* com.sprint.mission.discodeit.storage.LocalBinaryContentStorage.download*(..))")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Service로 끝나는 클래스의 모든 메소드로 pointcut을 지정하는게 더 간편할 수도 있어 보입니다~!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

요구사항에 해당 메소드들만 지정하라고 이해해서 저렇게 지정하였습니다..!
@pointcut("execution(* com.sprint.mission.discodeit.service..Service.(..))") 으로 수정하겠습니다!

Comment on lines +37 to 48
log.info("[{}] 비즈니스 이벤트 시작 - 작업: {}, 매개변수: {}", className, methodName, Arrays.toString(args));

try {
Object result = joinPoint.proceed();
log.info("[{}] 비즈니스 이벤트 성공 - 작업: {}, 결과: {}", className, methodName, result);
return result;
} catch (Throwable throwable) {
log.error("[{}] 비즈니스 이벤트 실패 - 작업: {}, 예외: {}, 메시지: {}",
className, methodName, throwable.getClass().getSimpleName(), throwable.getMessage());
throw throwable;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

AOP를 이용하여 로깅과 관련된 공통 로직을 잘 분리해주셨습니다.
다만, 서비스별로 디버깅을 위해 봐야하는 특정 값들이 다를 수 있습니다. 서비스중에 디버깅에 도움이 될 만한 로깅을 일부 서비스에 추가로 남겨보면 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

우선 페이지네이션 관련하여 messageService.findAllByChannelId() 메서드를 추가하였습니다! 추후 더 추가하도록 하겠습니다!

Comment on lines 10 to 16
@AllArgsConstructor
@Getter
public class DiscodeitException extends RuntimeException {

final Instant timestamp;
final ErrorCode errorCode;
final Map<String, Object> details;
Copy link
Collaborator

Choose a reason for hiding this comment

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

AllArgsConstructor를 썼을 때, Map 객체가 그대로 details 멤버변수에 할당됩니다.
details 객체를 그대로 할당하면 어떤 문제가 생길 수 있을까요?

문제점

1. 불변성(Immutable) 보장 실패

  • details가 외부에서 전달된 Map<String, Object> 타입 그대로 할당되고 있습니다.
  • 만약 외부에서 전달된 details 맵이 이후에 변경된다면, DiscodeitException 객체 내부의 details도 함께 변경됩니다.
  • 이는 예외 객체의 상태가 예기치 않게 변할 수 있음을 의미하며, 예외 객체는 생성 이후 상태가 변하지 않는 것이 바람직합니다.

2. 캡슐화 위반

  • 외부에서 전달된 객체를 그대로 참조하므로, 예외 객체의 내부 상태가 외부에 노출됩니다.

개선 방법

1. 방어적 복사(Defensive Copy)

  • 생성자에서 전달받은 맵을 새로운 맵으로 복사하여 할당하면, 외부 변경으로부터 내부 상태를 보호할 수 있습니다.
public DiscodeitException(ErrorCode errorCode, Map<String, Object> details) {
    super(errorCode.getMessage());
    this.errorCode = errorCode;
    this.details = (details == null) ? null : new HashMap<>(details);
}

2. 불변 맵 사용

  • Java 9 이상이라면 Map.copyOf()를 사용할 수도 있습니다.
this.details = (details == null) ? null : Map.copyOf(details);

결론

  • 예외 객체의 내부 상태가 외부에 의해 변경될 수 있으므로, 방어적 복사를 통해 불변성을 보장하는 것이 좋습니다.
  • 특히 예외 객체는 로그나 디버깅 용도로 많이 사용되므로, 상태가 변하지 않도록 주의해야 합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오... 거기까진 생각을 못했는데 감사합니다!
this.details = details == null ? Map.of() : Map.copyOf(details); 으로 수정하였습니다!

Comment on lines 41 to 51
void createPublicChannelProcessIntegration() {
// given
PublicChannelCreateRequest publicChannelCreateRequest = new PublicChannelCreateRequest("test", "test");

// when
ChannelDto channelDto = channelService.create(publicChannelCreateRequest);

// then
Channel channel = channelRepository.findById(channelDto.id()).orElseThrow();
assertThat(channelDto.name()).isEqualTo(channel.getName());
assertThat(channelDto.id()).isEqualTo(channel.getId());
Copy link
Collaborator

Choose a reason for hiding this comment

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

MockMvc를 이용해서 json으로 요청을 보내는 방식으로 통합테스트를 작성해보면 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Channel, User, Message 통합테스트 MockMvc를 이용한 테스트로 수정했습니다!

@Override
List<User> findAll();
// @EntityGraph(attributePaths = {"userStatus", "profile"})
@Query("SELECT u FROM User u JOIN FETCH u.userStatus JOIN FETCH u.profile")
Copy link
Collaborator

Choose a reason for hiding this comment

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

fetch join이 동작하는지 테스트해볼 수 있을까요?

Hibernate.isInitialized(Object proxy) 는 Hibernate에서 프록시 객체나 지연 로딩(lazy loading) 컬렉션이 실제로 초기화(로딩)되었는지 여부를 확인하는 정적 메소드입니다. 이 메소드는 다음과 같은 상황에서 주로 사용됩니다.

  • 지연 로딩(lazy loading) 필드나 컬렉션이 실제 DB에서 로딩되었는지(초기화되었는지) 확인할 때
  • 세션이 닫힌 후 LazyInitializationException이 발생하지 않도록, 접근 전에 초기화 여부를 미리 체크할 때

동작 방식

  • proxy 또는 persistent collection 객체가 전달되면,
    • 이미 초기화(로딩)된 경우 true 반환
    • 아직 초기화되지 않은 경우 false 반환
    • 일반 객체(프록시나 컬렉션이 아닌 경우)는 항상 true 반환

public static boolean isInitialized(java.lang.Object proxy)
Check if the proxy or persistent collection is initialized.
Returns: true if the argument is already initialized, or is not a proxy or collection.

예시 코드

if (!Hibernate.isInitialized(entity.getLazyCollection())) {
    Hibernate.initialize(entity.getLazyCollection());
}
  • 위 예시처럼, 컬렉션이나 연관 엔티티가 초기화되지 않았다면 Hibernate.initialize()로 강제 초기화할 수 있습니다.

활용 시 주의사항

  • Detached 상태(세션이 닫힌 후)에서는 초기화할 수 없으므로, 반드시 세션이 열려 있을 때 사용해야 합니다.
  • 컬렉션의 경우, 컬렉션 객체 자체의 초기화 여부만 판단합니다. 컬렉션 내부의 요소까지 모두 초기화되었는지는 보장하지 않습니다.

요약

  • **Hibernate.isInitialized(obj)**는 해당 객체(프록시, 컬렉션)가 실제로 DB에서 로딩되었는지 확인하는 메소드입니다.
  • Lazy Loading 환경에서 안전하게 객체 접근이 필요한 경우, 이 메소드로 초기화 여부를 확인 후 사용하세요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fetch join을 사용했을 때 profile이 없는 user는 검색결과에 제외되어, 전체 유저 조회 시 검색이 안되는 문제 때문에 @entitygraph(attributePaths = {"userStatus", "profile"})로 수정하였습니다!

Comment on lines +107 to +129
@Test
@DisplayName("커서 기반으로 이전 메시지를 조회할 수 있다")
void findByChannelIdAndCreatedAtLessThanOrderByCreatedAtDesc() {
// given
UUID channelId = channel.getId();
Pageable pageable = PageRequest.of(0, 10, Sort.by("createdAt").descending());
List<Message> messages = messageRepository
.findByChannelIdOrderByCreatedAtDesc(channelId, pageable)
.getContent();

Message cursorTarget = messages.get(0);
Instant cursor = cursorTarget.getCreatedAt();
cursor = cursor.atOffset(ZoneOffset.UTC).toInstant();

// when
Slice<Message> result = messageRepository.findByChannelIdAndCreatedAtLessThanOrderByCreatedAtDesc(
channelId, cursor, pageable);


// then
assertThat(result.getContent()).hasSize(2);
assertThat(result.getContent().get(0).getContent()).isEqualTo("내용 1");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 테스트가 실패하고 있습니다. 확인 부탁드려요~!
스크린샷 2025-07-01 오후 11 11 54

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 부분 때문에 애를 먹었는데.. H2와 JVM의 Time-zone이 맞지 않아 테스트가 실패했습니다.
jap.properties.hibernate.jdbc.time_zone: UTC로 맞추고 테스트를 돌리니까 단일 테스트는 통과하는데,
전체 테스트는 실패하는 상황이...
build.gradle에
test {
jvmArgs "-Duser.timezone=UTC"
}
적어주고 전체 테스트까지 통과하는것 확인했습니다...!

Comment on lines 12 to 19
public class ErrorResponse {
String code;
String message;
Map<String, Object> details;
String exceptionType;
int status;
private Instant timestamp;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

생성자 사용시, 멤버변수 순서가 달라서 빌드가 안됩니다. 아래와 같이 순서 수정이 필요합니다. 그리고 private 접근 제어자가 timestamp에만 들어갔는데 다른 부분에는 넣지 않은 이유가 있으실까요?

public class ErrorResponse {
    private Instant timestamp;
    String code;
    String message;
    Map<String, Object> details;
    String exceptionType;
    int status;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

변수 순서 맞춰서 인스턴스 생성하는 부분을 수정하였습니다!
접근 제어자는 실수로 빼먹고 안 적은 것 같습니다..

질문이 있는데 이번 상황처럼 멤버 변수 순서가 달랐는데 제 경우에는 컴파일 오류가 안뜨고 성공적으로 application run이 돌아갔는데, 해당 클래스를 확인하니까 컴파일 오류가 뜨더라구요.. 이런 경우도 있나요??

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