-
Notifications
You must be signed in to change notification settings - Fork 306
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
๐ 3๋จ๊ณ - ์งํ์ฒ ๊ตฌ๊ฐ ๊ด๋ฆฌ #968
base: nice7677
Are you sure you want to change the base?
Conversation
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.
3๋จ๊ณ ๋ฏธ์
๋ ์ ๊ตฌํํด์ฃผ์
จ๋ค์.
Line๊ณผ Section, Station, Stations๊ฐ์ ๊ด๊ณ์ ๋ํด ๋ค์ ํ๋ฒ ๊ณ ๋ฏผํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ๐
์ฝ๋ฉํธ ๋จ๊ฒผ์ผ๋ ํ์ธํด์ฃผ์๊ณ , ๋ค์ ๋ฆฌ๋ทฐ ์์ฒญ์ฃผ์ธ์!
README.md
Outdated
- [ ] ์งํ์ฒ ๋ ธ์ ์ ๊ตฌ๊ฐ์ ๋ฑ๋ก | ||
- [ ] ์๋ก์ด ๊ตฌ๊ฐ์ ์ํ์ญ์ ํด๋น ๋ ธ์ ์ ๋ฑ๋ก๋์ด์๋ ํํ ์ข ์ ์ญ์ด์ด์ผ ํ๋ค. | ||
- [ ] ์๋ก์ด ๊ตฌ๊ฐ์ ํํ์ญ์ ํด๋น ๋ ธ์ ์ ๋ฑ๋ก๋์ด์๋ ์ญ์ผ ์ ์๋ค. | ||
- [ ] ์๋ก์ด ๊ตฌ๊ฐ ๋ฑ๋ก์ ์ ์กฐ๊ฑด์ ๋ถํฉํ์ง ์๋ ๊ฒฝ์ฐ ์๋ฌ ์ฒ๋ฆฌํ๋ค. |
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.
๊ตฌํํ ์ฌํญ์ ์ฒดํฌ ํ์ํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์.
@ManyToOne | ||
@JoinColumn(name = "station_id", nullable = false) | ||
private Station station; | ||
|
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.
Station์ด ์๋๋ผ Stations๊ฐ ๋ค์ด๊ฐ์ผ ํ์ง ์์๊น์? ๐ค Stations์ Section์ ์ฐ๊ฒฐ๊ณ ๋ฆฌ๊ฐ ์์ด๋ณด์ฌ์.
๊ทธ๋ฆฌ๊ณ line์์ section์ ๊ฐ์ง๊ณ ์์ด์ผ ํ ๊น์? stations์ ๊ฐ์ง๊ณ ์์ด์ผ ํ ๊น์? ์ ๋ถ๋ถ์ ๋ํด ๊ณ ๋ฏผํด๋ด์ฃผ์ธ์!
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.
์๊ฐ๋ชปํ๋ค์ ๊ทธ๋ ๊ฒํ๋ฉด ํด๊ฒฐ๋๋ ๋ฌธ์ ์๋๋ฐ ๋๊ณ ๋์์ ๋ง๋ค์๋ค์๐
public static LineResponse of(Line route) { | ||
return new LineResponse(route); | ||
} |
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.
์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋ ์ฌ์ฉ ๐
Map<String, String> params = new HashMap<>(); | ||
params.put("upStationId", "1"); | ||
params.put("downStationId", "2"); | ||
params.put("distance", "10"); | ||
|
||
Long lineId = 1L; | ||
|
||
ExtractableResponse<Response> createSectionResponse = RestAssuredUtils.create(new RestAssuredCondition(String.format(LINE_SECTION_API_URI, lineId), params)); | ||
assertThat(createSectionResponse.statusCode()).isEqualTo(500); | ||
|
||
|
||
Map<String, String> stationParams = new HashMap<>(); | ||
stationParams.put("name", "์์ง๋ก์ญ"); | ||
RestAssuredUtils.create(new RestAssuredCondition(STATION_API_URI, stationParams)); | ||
|
||
|
||
params.put("upStationId", "2"); | ||
params.put("downStationId", "3"); | ||
params.put("distance", "10"); | ||
createSectionResponse = RestAssuredUtils.create(new RestAssuredCondition(String.format(LINE_SECTION_API_URI, lineId), params)); | ||
assertThat(createSectionResponse.statusCode()).isEqualTo(201); | ||
|
||
ExtractableResponse<Response> deleteSectionResponse = RestAssuredUtils.delete(new RestAssuredCondition(String.format(LINE_SECTION_API_URI + "?stationId=%s", lineId, 3))); | ||
assertThat(deleteSectionResponse.statusCode()).isEqualTo(204); | ||
|
||
ExtractableResponse<Response> getSectionResponse = RestAssuredUtils.inquiry(new RestAssuredCondition(String.format(LINE_SECTION_API_URI, lineId))); | ||
|
||
assertThat(getSectionResponse.statusCode()).isEqualTo(200); | ||
|
||
List<SectionResponse> sectionResponses = getSectionResponse.body().jsonPath().getList(".", SectionResponse.class); | ||
|
||
assertThat(sectionResponses.size()).isEqualTo(2); | ||
assertThat(sectionResponses.get(0).getStationId()).isEqualTo(1L); | ||
assertThat(sectionResponses.get(1).getStationId()).isEqualTo(2L); |
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.
์ธ์ ํ ์คํธ ์ฝ๋๊ฐ ๊ธธ๊ณ ํ ์คํธ ์ค๊ฐ์ค๊ฐ assertThat์ด ๋ค์ด๊ฐ ์์ด์ ํ๋์ ์๋ค์ด์ค๋ ๊ฒ ๊ฐ์์. ๐ given, when, then ์ฃผ์์ผ๋ก ๊ตฌ๋ถํด์ฃผ๋ฉด ์ด๋จ๊น์? ํ ์คํธ ์๋๋ฆฌ์ค๋ ๊ฐ์ด ์์ผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์.
return sectionService.getSections(line) | ||
.stream() | ||
.sorted(Comparator.comparing(Section::getId)) | ||
.map(section -> { | ||
return SectionResponse.of(section); | ||
}) | ||
.collect(Collectors.toList()); |
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.
id ์์๋ก sortingํ๋ ์ด์ ๊ฐ ์์๊น์? id๋ฅผ ์์ ์นผ๋ผ์ผ๋ก ์ฌ์ฉํด๋ ๊ด์ฐฎ์๊น์? ๐ค
private void validateSection(List<Section> sections, Section section) { | ||
|
||
} |
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.
์ฌ์ฉํ์ง ์๋ ์ฝ๋๋ ์ง์์ฃผ์ธ์.
@DisplayName("๊ตฌ๊ฐ ์ ๊ฑฐ ๊ธฐ๋ฅ") | ||
@Test | ||
void deleteSection() { |
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.
๊ตฌ๊ฐ ์ ๊ฑฐ ์์ธ ์ผ์ด์ค์ ๋ํ ๊ฒ์ฆ์ด ์์ด์. ๐ญ
๊ตฌ๊ฐ ๊ด๋ฆฌ ๊ธฐ๋ฅ์ ์์ธ ์ผ์ด์ค๋ฅผ ๊ณ ๋ คํ๊ธฐ
-๊ตฌ๊ฐ ๋ฑ๋ก๊ณผ ์ ๊ฑฐ ๊ธฐ๋ฅ์ ์์ธ์ผ์ด์ค๋ค์ ๋ํ ์๋๋ฆฌ์ค๋ฅผ ์ ์
-์ธ์ ํ ์คํธ๋ฅผ ์์ฑํ๊ณ ์ด๋ฅผ ๋ง์กฑ์ํค๋ ๊ธฐ๋ฅ์ ๊ตฌํ
@DisplayName("๊ตฌ๊ฐ ๋ฑ๋ก ๊ธฐ๋ฅ") | ||
@Test | ||
void createSection() { |
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.
๊ตฌ๊ฐ ๋ฑ๋ก ์์ธ ์ผ์ด์ค์ ๋ํ ๊ฒ์ฆ์ด ์์ด์. ๐ญ
๊ตฌ๊ฐ ๊ด๋ฆฌ ๊ธฐ๋ฅ์ ์์ธ ์ผ์ด์ค๋ฅผ ๊ณ ๋ คํ๊ธฐ
-๊ตฌ๊ฐ ๋ฑ๋ก๊ณผ ์ ๊ฑฐ ๊ธฐ๋ฅ์ ์์ธ์ผ์ด์ค๋ค์ ๋ํ ์๋๋ฆฌ์ค๋ฅผ ์ ์
-์ธ์ ํ ์คํธ๋ฅผ ์์ฑํ๊ณ ์ด๋ฅผ ๋ง์กฑ์ํค๋ ๊ธฐ๋ฅ์ ๊ตฌํ
์๋ ํ์ธ์.
JPA๋ฅผ ์ ์ด์ง ์ข ๋ผ์ ๋ง์ด ๊น๋จน์ด์ ๋งคํ ๋ถ๋ถ์์ ์ฝ๋๊ฐ ์ข ๋๋ฝ์ต๋๋ค.