-
Notifications
You must be signed in to change notification settings - Fork 0
Board CRUD 기본 완성 입니다. #7
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
base: review/java
Are you sure you want to change the base?
Conversation
Board Model 과 Repository 에 한하여 Test 작성
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| @Repository |
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 BoardRepository boardRepository; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { |
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.
BeforeEach로 매번 생성하기 보다는 BoardRepository를 빈으로 등록해놨으니 빈 주입을 받아서 쓰는게 어떨까요?
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.
그거 @bean 으로 했더니 객체를 한번만 만들더라구요.. Test Isolation 이 안되서 어쩔수 없이 매번 생성하였습니다. Isolation 하는 방법좀 알려주세요.
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.
@mingimin 원래 의도하신게 Isolation이면 지금처럼 해도 좋을 것 같습니다 👍 제가 착각했네요 죄송합니다
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.
Repository에서 데이터를 직접 들고 관리하다보니 이런 문제가 생겼군요. DB를 사용하게되면 트랜잭션 레벨로 분리가 되겠지만,
한번 자바스타일에 맞게끔 분리해보는 것도 좋을것 같네요!
| private String title; | ||
| private String body; | ||
|
|
||
| public static class Builder { |
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.
Builder패턴....!!
| } | ||
|
|
||
| @PostMapping("/board") | ||
| public ResponseEntity<BoardCreateResponse> create(@RequestBody HashMap<String, Object> map) { |
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.
(@RequestBody Board board)
이런식으로 받아올 수 있어요.
빌더 연습하려고 하신거면 죄송
| private BoardRepository boardRepository; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { |
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.
Repository에서 데이터를 직접 들고 관리하다보니 이런 문제가 생겼군요. DB를 사용하게되면 트랜잭션 레벨로 분리가 되겠지만,
한번 자바스타일에 맞게끔 분리해보는 것도 좋을것 같네요!
| assertNotEquals(title, updatedBoard.getTitle()); | ||
| assertEquals(newTitle, updatedBoard.getTitle()); | ||
| assertNotEquals(body, updatedBoard.getBody()); | ||
| assertEquals(newBody, updatedBoard.getBody()); |
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로 구현하신건가요??
Board Model 과 Repository 에 한하여 기본 Test 만 작성하였습니다.