-
Notifications
You must be signed in to change notification settings - Fork 0
Point, Points 도메인 구현 #2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: feature/fuel-injection
Are you sure you want to change the base?
Point, Points 도메인 구현 #2
Conversation
b903e7b
to
d547f04
Compare
|
||
@Test | ||
void 객체비교테스트2() { | ||
assertNotEquals(new Points("(10,10)-(14,15)"), new Points("(10,9)-(14,15)")); |
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.
객체간의 비교는 getter를 사용하는것이 아닌 equals, hashcode를 구현해서 객체간 비교를 한다
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.
음주 리뷰,,(술냄새가 풍긴다면 죄송쓰)
class PointsTest { | ||
|
||
@ParameterizedTest | ||
@CsvSource({"ashjkd", "(10,10,123)-(14,15)", "(10,10)-(14,151,123)", "12379612679"}) |
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.
valueSource, methodSource말고 csvsource도 있었군요..!
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.
근데 valueSource랑 어떤 차이가 있나요..?
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.
원래는 csv file에서 테스트 stub을 가져오기 위해 사용하는 어노테이션.. 파일경로 입력가능. 근데 valueSource처럼 쓸 수도 있습니다. methodSource는 첨들어보는데 무엇에 쓰는 물건인고?
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.
지난번 레이싱 경주 코드 중 CarsTest에서 가져왔습니당
Stream를 리턴해서 테스트 데이터s의 인자들을 정의해서 넘길 수 있습니당!
@ParameterizedTest
@MethodSource("invalidParameters")
@DisplayName("잘못된 자동차 이름 에러 테스트")
void test(String parameter, String name) {
InvalidCarNameException invalidCarNameException = assertThrows(InvalidCarNameException.class, () -> new Cars(parameter));
assertEquals(name, invalidCarNameException.getMessage());
}
static Stream<Arguments> invalidParameters() {
return Stream.of(
Arguments.of("", ErrorMessage.CarName.NOT_ALLOW_EMPTY_OR_CONTAINS_WHITE_SPACE),
Arguments.of(" ", ErrorMessage.CarName.NOT_ALLOW_EMPTY_OR_CONTAINS_WHITE_SPACE),
Arguments.of("onlyOneCar", ErrorMessage.CarName.NOT_EXIST_COMMA),
Arguments.of("12345,123456", ErrorMessage.CarName.NOT_EXCEED_CAR_NAME_LENGTH),
Arguments.of(",car", ErrorMessage.CarName.NOT_START_WITH_COMMA),
Arguments.of("car,", ErrorMessage.CarName.NOT_END_WITH_COMMA),
Arguments.of("car1,car1,car2", ErrorMessage.CarName.NOT_DUPLICATE_CAR_NAME)
);
}
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(points); |
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.
혹시 인텔리제이 자동 추천 코드인가요?
전 커뮤니티 라이센스가 종료되서 부득이하게 VSCode로 작성했는데
VScode에서는 @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((points == null) ? 0 : points.hashCode()); return result; }
이런 식으로 추천해주더라구요..
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.
hash collision 막기 위해서 상대적으로 작은 소수를 곱하는데 그게 보통 31입니다
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.
테스트 stub, hashcollision,,, 공부할게 많네여ㅎㅎ
|
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.
문서가 자세해서 너무 좋습니다ㅎㅎ 덩달아 힌트도 얻어가네요!
TDD로 구현해본 도메인