-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Week5] 고양이 장난감가게 만들기 - 심화 #61
Conversation
@@ -66,6 +67,27 @@ void setUp() { | |||
})); | |||
} | |||
|
|||
@Nested | |||
@DisplayName("유효하지 요청 데이터가 오면") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
유효하지 않은 요청 데이터도 좋지만 값을 가진 데이터라는 구체적인 예시를 적는 것이 좋을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 제가 제대로 이해를 못한거 같아요 ㅜㅜ
빈 값을 가진 요청 데이터가 오면 이렇게 이런 식으로 구체적인 값이 뭔지 예시를 적는게 맞을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요!
특정 데이터들이 빈 문자열을 가지는 경우이기에 그것들을 명시하면 좋겠어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
또한 현재는 모든 데이터가 빈 문자열일 때지만
각 변수마다 빈 값이 허용될 수도 있으므로 테스트를 나눠보는 것도 좋겠어요!
app/src/main/java/com/codesoom/assignment/application/UserService.java
Outdated
Show resolved
Hide resolved
@DisplayName("user를 삭제한다.") | ||
void it_deletes_user() { | ||
userService.deleteUser(id); | ||
|
||
assertThatThrownBy(() -> userRepository.findById(id).get()) | ||
.isInstanceOf(NoSuchElementException.class); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
설명과 테스트가 다른 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
설명과 테스트가 다른 것 같아요!
삭제를 하고 user를 조회해서 제대로 삭제 되어있는지 검증 하는 로직인데
이 부분에 대해서 제대로 이해가 안돼서 그런데 ㅜㅜ 혹시 추가 설명좀 해주실수 있나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user를 삭제하는 것을 테스트하는 것이 아니라 예외를 테스트하고 있기 때문입니다!
@NotBlank | ||
private final String name; | ||
|
||
@NotBlank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋아요! NotBlank는 아주 유용하죠!
실행활에서는 좀 더 복잡한 유효성검사를 테스트해보기도 해요!
한번 password 변수는 커스텀 Validator를 만들어서 접목해보는 시도를 하면 좋은 경험이될거에요!
app/src/main/java/com/codesoom/assignment/validation/MyPasswordValidator.java
Show resolved
Hide resolved
// 특수 문자, 영문, 숫자 3종류를 조합해야 한다. | ||
@Override | ||
public boolean isValid(String value, ConstraintValidatorContext context) { | ||
Pattern pattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,16}$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
똑같은 인스턴스를 매번 쓸 것 같아요! static으로 변경해도 좋을 것 같아요!
assertThat(myPasswordValidator.isValid(value, context)).isFalse(); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: eof에 빈칸을 추가해주세요!
@Getter | ||
public class UserSignupData { | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
실패시 리턴하는 메시지를 커스텀 해보면 좋은 경험이 될 것 같아요!
private Pattern pattern; | ||
@Override | ||
public void initialize(MyPassword constraintAnnotation) { | ||
pattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,16}$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이번 주 목표는 일일 리뷰 요청입니다! 잘 부탁드립니다 :)