We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> // Comment Entity import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; ... @Length(max = 1000, message = "댓글은 1000자를 초과할 수 없습니다.") @NotBlank(message = "댓글 내용은 비어 있을 수 없습니다.") private String content; // Test import static org.assertj.core.api.Assertions.assertThatThrownBy; ... @DisplayName("[예외] 댓글 내용은 1000자를 넘어서는 안된다.") @Test void commentIsTooLong() { // given final String tooLongComment = RandomStringUtils.randomAlphanumeric(1010); // when CommentCreateRequest request = CommentCreateRequest.builder() .content(tooLongComment) .lectureId(testLecture.getId()) .userId(testUser.getId()) .build(); // then assertThatThrownBy(() -> commentService.createComment(request.toEntity(), request.getUserId(), request.getLectureId())) .isInstanceOf(ConstraintViolationException.class) .hasMessageContaining("1000자"); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Assertions.assertThatThrownBy,
The text was updated successfully, but these errors were encountered: