From 63b978d31ca13ef1cc61c6e1a5fdbc006fb6a69a Mon Sep 17 00:00:00 2001 From: Jeonghoon Park <39729721+shb03323@users.noreply.github.com> Date: Thu, 27 Jul 2023 10:25:28 +0900 Subject: [PATCH] =?UTF-8?q?=ED=81=B4=EB=9D=BC=EC=9D=B4=EC=96=B8=ED=8A=B8?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=EB=A5=BC=20=EC=9C=84=ED=95=9C=20Validator?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20(#117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: ClientRequestException 일반 클래스로 변경 * refactor: ErrorResponse 에서 httpStatus 제거 * refactor: RunnerPostUpdateRequest record로 변경 * refactor: ClientErrorCode 내용 추가 * refactor: record로 생긴 변화 적용 * feat: NotNullValid 어노테이션 추가 * refactor: ErrorResponse 에 getter 추가 * feat: Controller valid 추가 * feat: ValidFuture 어노테이션 추가 * feat: 어노테이션 이름 변경 * feat: Max validator 추가 * feat: request dto에 validation 적용 * refactor: 어노테이션 target 조정 * refactor: tag 값이 없을 때 Bad Request 보내도록 수정 --- .../domain/common/GlobalControllerAdvice.java | 16 +++ .../common/exception/ClientErrorCode.java | 11 +- .../exception/ClientRequestException.java | 2 +- .../exception/validator/NotNullValidator.java | 24 +++++ .../exception/validator/ValidNotNull.java | 38 +++++++ .../domain/common/response/ErrorResponse.java | 9 +- .../controller/RunnerPostController.java | 7 +- .../exception/validator/FutureValidator.java | 26 +++++ .../validator/MaxLengthValidator.java | 26 +++++ .../exception/validator/ValidFuture.java | 28 +++++ .../exception/validator/ValidMaxLength.java | 30 ++++++ .../runnerpost/service/RunnerPostService.java | 10 +- .../service/dto/RunnerPostCreateRequest.java | 15 ++- .../service/dto/RunnerPostUpdateRequest.java | 101 +++--------------- .../service/RunnerPostServiceUpdateTest.java | 2 +- 15 files changed, 242 insertions(+), 103 deletions(-) create mode 100644 backend/baton/src/main/java/touch/baton/domain/common/GlobalControllerAdvice.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/common/exception/validator/NotNullValidator.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/common/exception/validator/ValidNotNull.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/FutureValidator.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/MaxLengthValidator.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidFuture.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidMaxLength.java diff --git a/backend/baton/src/main/java/touch/baton/domain/common/GlobalControllerAdvice.java b/backend/baton/src/main/java/touch/baton/domain/common/GlobalControllerAdvice.java new file mode 100644 index 000000000..55a67a09f --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/common/GlobalControllerAdvice.java @@ -0,0 +1,16 @@ +package touch.baton.domain.common; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import touch.baton.domain.common.exception.ClientRequestException; +import touch.baton.domain.common.response.ErrorResponse; + +@RestControllerAdvice +public class GlobalControllerAdvice { + + @ExceptionHandler(ClientRequestException.class) + public ResponseEntity handleClientRequest(ClientRequestException e) { + return ResponseEntity.status(e.getHttpStatus().value()).body(ErrorResponse.from(e)); + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientErrorCode.java b/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientErrorCode.java index 55c6a87bc..8ab11e4d8 100644 --- a/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientErrorCode.java +++ b/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientErrorCode.java @@ -3,7 +3,16 @@ import org.springframework.http.HttpStatus; public enum ClientErrorCode implements ErrorCode { - ; + + TITLE_IS_NULL(HttpStatus.BAD_REQUEST, "RP001", "제목을 입력해주세요."), + PULL_REQUEST_URL_IS_NULL(HttpStatus.BAD_REQUEST, "RP002", "PR 주소를 입력해주세요."), + DEADLINE_IS_NULL(HttpStatus.BAD_REQUEST, "RP003", "마감일을 입력해주세요."), + CONTENTS_ARE_NULL(HttpStatus.BAD_REQUEST, "RP004", "내용을 입력해주세요."), + CONTENTS_OVERFLOW(HttpStatus.BAD_REQUEST, "RP005", "내용은 1000자 까지 입력해주세요."), + PAST_DEADLINE(HttpStatus.BAD_REQUEST, "RP006", "마감일은 오늘보다 과거일 수 없습니다."), + CONTENTS_NOT_FOUND(HttpStatus.NOT_FOUND, "RP007", "존재하지 않는 게시물입니다."), + TAGS_ARE_NULL(HttpStatus.BAD_REQUEST, "RP008", "태그 목록을 빈 값이라도 입력해주세요."); + private final HttpStatus httpStatus; private final String errorCode; private final String message; diff --git a/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientRequestException.java b/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientRequestException.java index c8801c5f0..9c83378c4 100644 --- a/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientRequestException.java +++ b/backend/baton/src/main/java/touch/baton/domain/common/exception/ClientRequestException.java @@ -1,6 +1,6 @@ package touch.baton.domain.common.exception; -public abstract class ClientRequestException extends BaseException { +public class ClientRequestException extends BaseException { public ClientRequestException(final ClientErrorCode errorCode) { super(errorCode); diff --git a/backend/baton/src/main/java/touch/baton/domain/common/exception/validator/NotNullValidator.java b/backend/baton/src/main/java/touch/baton/domain/common/exception/validator/NotNullValidator.java new file mode 100644 index 000000000..bb3ea1f71 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/common/exception/validator/NotNullValidator.java @@ -0,0 +1,24 @@ +package touch.baton.domain.common.exception.validator; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import touch.baton.domain.common.exception.ClientErrorCode; +import touch.baton.domain.common.exception.ClientRequestException; + +public class NotNullValidator implements ConstraintValidator { + + private ClientErrorCode errorCode; + + @Override + public void initialize(final ValidNotNull constraintAnnotation) { + errorCode = constraintAnnotation.clientErrorCode(); + } + + @Override + public boolean isValid(final Object value, final ConstraintValidatorContext context) { + if (value == null) { + throw new ClientRequestException(errorCode); + } + return true; + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/common/exception/validator/ValidNotNull.java b/backend/baton/src/main/java/touch/baton/domain/common/exception/validator/ValidNotNull.java new file mode 100644 index 000000000..571b66590 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/common/exception/validator/ValidNotNull.java @@ -0,0 +1,38 @@ +package touch.baton.domain.common.exception.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import touch.baton.domain.common.exception.ClientErrorCode; + +import java.lang.annotation.Documented; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({ FIELD, PARAMETER }) +@Retention(RUNTIME) +@Repeatable(ValidNotNull.List.class) +@Documented +@Constraint(validatedBy = NotNullValidator.class) +public @interface ValidNotNull { + + String message() default "null 값이 존재합니다."; + + Class[] groups() default {}; + + Class[] payload() default {}; + + ClientErrorCode clientErrorCode(); + + @Target({ FIELD, PARAMETER }) + @Retention(RUNTIME) + @Documented + @interface List { + + ValidNotNull[] value(); + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/common/response/ErrorResponse.java b/backend/baton/src/main/java/touch/baton/domain/common/response/ErrorResponse.java index f471af045..5cf4c6060 100644 --- a/backend/baton/src/main/java/touch/baton/domain/common/response/ErrorResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/common/response/ErrorResponse.java @@ -1,21 +1,20 @@ package touch.baton.domain.common.response; -import org.springframework.http.HttpStatus; +import lombok.Getter; import touch.baton.domain.common.exception.BaseException; +@Getter public class ErrorResponse { - private final HttpStatus status; private final String errorCode; private final String message; - private ErrorResponse(final HttpStatus status, final String errorCode, final String message) { - this.status = status; + private ErrorResponse(final String errorCode, final String message) { this.errorCode = errorCode; this.message = message; } public static ErrorResponse from(final BaseException e) { - return new ErrorResponse(e.getHttpStatus(), e.getErrorCode(), e.getMessage()); + return new ErrorResponse(e.getErrorCode(), e.getMessage()); } } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostController.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostController.java index 26a37a229..8e51835fc 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostController.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostController.java @@ -1,5 +1,6 @@ package touch.baton.domain.runnerpost.controller; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -32,7 +33,7 @@ public class RunnerPostController { private final RunnerService runnerService; @PostMapping - public ResponseEntity createRunnerPost(@RequestBody RunnerPostCreateRequest request) { + public ResponseEntity createRunnerPost(@Valid @RequestBody RunnerPostCreateRequest request) { // TODO 07/19 로그인 기능 개발시 1L 변경 요망 Runner runner = runnerService.readRunnerWithMember(1L); @@ -46,7 +47,7 @@ public ResponseEntity createRunnerPost(@RequestBody RunnerPostCreateReques } @PostMapping("/test") - public ResponseEntity createRunnerPostVersionTest(@RequestBody RunnerPostCreateTestRequest request) { + public ResponseEntity createRunnerPostVersionTest(@Valid @RequestBody RunnerPostCreateTestRequest request) { // TODO 07/19 로그인 기능 개발시 1L 변경 요망 Runner runner = runnerService.readRunnerWithMember(1L); @@ -84,7 +85,7 @@ public ResponseEntity deleteByRunnerPostId(@PathVariable final Long runner @PutMapping("/{runnerPostId}") public ResponseEntity update(@PathVariable final Long runnerPostId, - @RequestBody final RunnerPostUpdateRequest request + @Valid @RequestBody final RunnerPostUpdateRequest request ) { final Long updatedId = runnerPostService.updateRunnerPost(runnerPostId, request); final URI redirectUri = UriComponentsBuilder.fromPath("/api/v1/posts/runner") diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/FutureValidator.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/FutureValidator.java new file mode 100644 index 000000000..64239752b --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/FutureValidator.java @@ -0,0 +1,26 @@ +package touch.baton.domain.runnerpost.exception.validator; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import touch.baton.domain.common.exception.ClientErrorCode; +import touch.baton.domain.common.exception.ClientRequestException; + +import java.time.LocalDateTime; + +public class FutureValidator implements ConstraintValidator { + + private ClientErrorCode errorCode; + + @Override + public void initialize(final ValidFuture constraintAnnotation) { + errorCode = constraintAnnotation.clientErrorCode(); + } + + @Override + public boolean isValid(final LocalDateTime value, final ConstraintValidatorContext context) { + if (value.isBefore(LocalDateTime.now())) { + throw new ClientRequestException(errorCode); + } + return true; + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/MaxLengthValidator.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/MaxLengthValidator.java new file mode 100644 index 000000000..2acb27d41 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/MaxLengthValidator.java @@ -0,0 +1,26 @@ +package touch.baton.domain.runnerpost.exception.validator; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import touch.baton.domain.common.exception.ClientErrorCode; +import touch.baton.domain.common.exception.ClientRequestException; + +public class MaxLengthValidator implements ConstraintValidator { + + private ClientErrorCode errorCode; + private int max; + + @Override + public void initialize(final ValidMaxLength constraintAnnotation) { + errorCode = constraintAnnotation.clientErrorCode(); + max = constraintAnnotation.max(); + } + + @Override + public boolean isValid(final String value, final ConstraintValidatorContext context) { + if (value.length() > max) { + throw new ClientRequestException(errorCode); + } + return true; + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidFuture.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidFuture.java new file mode 100644 index 000000000..2ff689d7b --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidFuture.java @@ -0,0 +1,28 @@ +package touch.baton.domain.runnerpost.exception.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import touch.baton.domain.common.exception.ClientErrorCode; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({ FIELD, PARAMETER }) +@Retention(RUNTIME) +@Documented +@Constraint(validatedBy = FutureValidator.class) +public @interface ValidFuture { + + String message() default "마감일은 오늘보다 과거일 수 없습니다."; + + Class[] groups() default {}; + + Class[] payload() default {}; + + ClientErrorCode clientErrorCode(); +} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidMaxLength.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidMaxLength.java new file mode 100644 index 000000000..7aaf02477 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/exception/validator/ValidMaxLength.java @@ -0,0 +1,30 @@ +package touch.baton.domain.runnerpost.exception.validator; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import touch.baton.domain.common.exception.ClientErrorCode; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Target({ FIELD, PARAMETER}) +@Retention(RUNTIME) +@Documented +@Constraint(validatedBy = MaxLengthValidator.class) +public @interface ValidMaxLength { + + String message() default "길이가 잘못되었습니다."; + + Class[] groups() default {}; + + Class[] payload() default {}; + + ClientErrorCode clientErrorCode(); + + int max(); +} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java index a7b86e110..292d2566d 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostService.java @@ -147,10 +147,10 @@ public Long updateRunnerPost(final Long runnerPostId, final RunnerPostUpdateRequ // TODO: 메소드 분리 final RunnerPost runnerPost = runnerPostRepository.findById(runnerPostId) .orElseThrow(() -> new IllegalArgumentException("잘못된 runnerPostId 입니다.")); - runnerPost.updateTitle(new Title(request.getTitle())); - runnerPost.updateContents(new Contents(request.getContents())); - runnerPost.updatePullRequestUrl(new PullRequestUrl(request.getPullRequestUrl())); - runnerPost.updateDeadLine(new Deadline(request.getDeadline())); + runnerPost.updateTitle(new Title(request.title())); + runnerPost.updateContents(new Contents(request.contents())); + runnerPost.updatePullRequestUrl(new PullRequestUrl(request.pullRequestUrl())); + runnerPost.updateDeadLine(new Deadline(request.deadline())); final List presentRunnerPostTags = runnerPostTagRepository.joinTagByRunnerPostId(runnerPost.getId()); @@ -162,7 +162,7 @@ public Long updateRunnerPost(final Long runnerPostId, final RunnerPostUpdateRequ // TODO: 새로운 tag 로 교체 메소드 분리 final List removedRunnerPostTags = new ArrayList<>(presentRunnerPostTags); - for (String tagName : request.getTags()) { + for (String tagName : request.tags()) { final Optional existRunnerPostTag = presentRunnerPostTags.stream() .filter(presentRunnerPostTag -> presentRunnerPostTag.isSameTagName(tagName)) .findFirst(); diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostCreateRequest.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostCreateRequest.java index a3ec60d34..d97cd787c 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostCreateRequest.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostCreateRequest.java @@ -1,15 +1,24 @@ package touch.baton.domain.runnerpost.service.dto; -import com.fasterxml.jackson.annotation.JsonFormat; +import touch.baton.domain.common.exception.ClientErrorCode; +import touch.baton.domain.common.exception.validator.ValidNotNull; +import touch.baton.domain.runnerpost.exception.validator.ValidFuture; +import touch.baton.domain.runnerpost.exception.validator.ValidMaxLength; import java.time.LocalDateTime; import java.util.List; -public record RunnerPostCreateRequest(String title, +public record RunnerPostCreateRequest(@ValidNotNull(clientErrorCode = ClientErrorCode.TITLE_IS_NULL) + String title, + @ValidNotNull(clientErrorCode = ClientErrorCode.TAGS_ARE_NULL) List tags, + @ValidNotNull(clientErrorCode = ClientErrorCode.PULL_REQUEST_URL_IS_NULL) String pullRequestUrl, - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") + @ValidNotNull(clientErrorCode = ClientErrorCode.DEADLINE_IS_NULL) + @ValidFuture(clientErrorCode = ClientErrorCode.PAST_DEADLINE) LocalDateTime deadline, + @ValidNotNull(clientErrorCode = ClientErrorCode.CONTENTS_ARE_NULL) + @ValidMaxLength(clientErrorCode = ClientErrorCode.CONTENTS_OVERFLOW, max = 1000) String contents ) { } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostUpdateRequest.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostUpdateRequest.java index 054bb0404..9bfd636d2 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostUpdateRequest.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/dto/RunnerPostUpdateRequest.java @@ -1,91 +1,24 @@ package touch.baton.domain.runnerpost.service.dto; -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Getter; -import lombok.NoArgsConstructor; +import touch.baton.domain.common.exception.ClientErrorCode; +import touch.baton.domain.common.exception.validator.ValidNotNull; +import touch.baton.domain.runnerpost.exception.validator.ValidFuture; +import touch.baton.domain.runnerpost.exception.validator.ValidMaxLength; import java.time.LocalDateTime; import java.util.List; -import java.util.Objects; -@Getter -@NoArgsConstructor -public class RunnerPostUpdateRequest { -// TODO: 예외 처리, record 로 적용 - private static final int CONTENTS_MAX_LENGTH = 1000; - private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm"; - - private String title; - private List tags; - private String pullRequestUrl; - private LocalDateTime deadline; - private String contents; - - public RunnerPostUpdateRequest(final String title, - final List tags, - final String pullRequestUrl, - @JsonFormat(pattern = DATE_TIME_FORMAT) final LocalDateTime deadline, - final String contents - ) { - validate(title, tags, pullRequestUrl, deadline, contents); - this.title = title; - this.tags = tags; - this.pullRequestUrl = pullRequestUrl; - this.deadline = deadline; - this.contents = contents; - } - - private static void validate(final String title, - final List tags, - final String pullRequestUrl, - final LocalDateTime deadline, - final String contents - ) { - validateNotNull(title, tags, pullRequestUrl, deadline, contents); - validateContentsLength(contents); - validateDeadLine(deadline); - } - - private static void validateNotNull(final String title, - final List tags, - final String pullRequestUrl, - final LocalDateTime deadline, - final String contents - ) { - if (Objects.isNull(title)) { - throw new IllegalArgumentException("RP001"); - } - - if (Objects.isNull(tags)) { - throw new IllegalArgumentException("RP00???"); - } - - if (Objects.isNull(pullRequestUrl)) { - throw new IllegalArgumentException("RP002"); - } - - if (Objects.isNull(deadline)) { - throw new IllegalArgumentException("RP003"); - } - - if (Objects.isNull(contents)) { - throw new IllegalArgumentException("RP004"); - } - } - - private static void validateContentsLength(final String contents) { - if (contents.length() > CONTENTS_MAX_LENGTH) { - throw new IllegalArgumentException("RP005"); - } - } - - private static void validateDeadLine(final LocalDateTime deadline) { - validateDeadlineNotPassed(deadline); - } - - private static void validateDeadlineNotPassed(final LocalDateTime deadline) { - if (deadline.isBefore(LocalDateTime.now())) { - throw new IllegalArgumentException("RP006"); - } - } +public record RunnerPostUpdateRequest(@ValidNotNull(clientErrorCode = ClientErrorCode.TITLE_IS_NULL) + String title, + @ValidNotNull(clientErrorCode = ClientErrorCode.TAGS_ARE_NULL) + List tags, + @ValidNotNull(clientErrorCode = ClientErrorCode.PULL_REQUEST_URL_IS_NULL) + String pullRequestUrl, + @ValidNotNull(clientErrorCode = ClientErrorCode.DEADLINE_IS_NULL) + @ValidFuture(clientErrorCode = ClientErrorCode.PAST_DEADLINE) + LocalDateTime deadline, + @ValidNotNull(clientErrorCode = ClientErrorCode.CONTENTS_ARE_NULL) + @ValidMaxLength(clientErrorCode = ClientErrorCode.CONTENTS_OVERFLOW, max = 1000) + String contents +) { } diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java index a5da1cf7c..e8b387b6a 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java @@ -69,7 +69,7 @@ void success() { () -> assertThat(actual.getTitle()).isEqualTo(new Title(TITLE)), () -> assertThat(actual.getContents()).isEqualTo(new Contents(CONTENTS)), () -> assertThat(actual.getPullRequestUrl()).isEqualTo(new PullRequestUrl(PULL_REQUEST_URL)), - () -> assertThat(actual.getDeadline()).isEqualTo(new Deadline(request.getDeadline())) + () -> assertThat(actual.getDeadline()).isEqualTo(new Deadline(request.deadline())) ); final List runnerPostTags = runnerPostTagRepository.joinTagByRunnerPostId(savedId);