Skip to content
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단계 - μ§€ν•˜μ²  ꡬ간 관리 #970

Open
wants to merge 19 commits into
base: janeljs
Choose a base branch
from

Conversation

janeljs
Copy link

@janeljs janeljs commented Jul 29, 2023

μ†‘μš©μ£Ό λ¦¬λ·°μ–΄λ‹˜ μ•ˆλ…•ν•˜μ„Έμš”~
리뷰이 μž„μ§€μ„ μž…λ‹ˆλ‹€.

3단계 - μ§€ν•˜μ²  ꡬ간 관리 리뷰 μš”μ²­λ“œλ¦½λ‹ˆλ‹€.

ν•œ λ™μ•ˆ λ°”λΉ μ„œ μ•„μ˜ˆ λ―Έμ…˜μ„ λͺ»ν•˜λ‹€κ°€ λŠ¦κ²Œλ‚˜λ§ˆ μ‘°κΈˆμ”© 해보렀고 PR λ³΄λƒ…λ‹ˆλ‹€ 😭
μ €λ²ˆμ— λ‹΅λ³€μ£Όμ‹  μ½”λ©˜νŠΈλ“€ 도움이 많이 λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
이번 단계도 리뷰 잘 λΆ€νƒλ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€~! πŸ˜„

Copy link
Member

@testrace testrace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ•ˆλ…•ν•˜μ„Έμš” πŸ˜ƒ
3단계 κΉ”λ”ν•˜κ²Œ 잘 κ΅¬ν˜„ν•΄ μ£Όμ…¨λ„€μš” πŸ‘
λͺ‡ 가지 μ½”λ©˜νŠΈ λ‚¨κ²ΌλŠ”λ° 확인해 μ£Όμ‹œκ³  λ‹€μ‹œ 리뷰 μš”μ²­ν•΄ μ£Όμ„Έμš”

build.gradle Outdated
@@ -31,6 +31,7 @@ dependencies {
testImplementation 'io.rest-assured:rest-assured:4.5.1'
testImplementation 'com.navercorp.fixturemonkey:fixture-monkey-starter:0.5.8'
testImplementation 'com.google.guava:guava:16+'
testImplementation 'org.mockito:mockito-core'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” μ˜μ‘΄μ„±μ΄ μΆ”κ°€λ˜μ—ˆλ„€μš” πŸ‘€

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ‚­μ œν•˜μ˜€μŠ΅λ‹ˆλ‹€~! 348513e

import java.util.List;
import java.util.stream.Stream;

public class Sections {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일급 μ»¬λ ‰μ…˜ ν™œμš© πŸ‘

Comment on lines 23 to 32
public void validateUpStationId(Line line) {
if (!Objects.equals(upStationId, line.getTerminalStationId())) {
throw new InvalidSectionRequestException("ν•΄λ‹Ή λ…Έμ„ μ˜ ν•˜ν–‰μ’…μ μ—­μ΄ μ•„λ‹Œ 역이 μƒν–‰μ—­μœΌλ‘œ μ„€μ •λ˜μ—ˆμŠ΅λ‹ˆλ‹€.",
Map.of(
"lineId", line.getId().toString(),
"upStationId", upStationId.toString(),
"downStationId", downStationId.toString()
));
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도메인 둜직이 DTO에 ν¬ν•¨λœ 것 κ°™μ•„μš”
CreateSectionRequestλ₯Ό ν™œμš©ν•˜μ§€ μ•Šκ³  ꡬ간을 μΆ”κ°€ν•œλ‹€λ©΄ ꡬ간 μΆ”κ°€ μ œμ•½μ„ λ¬΄μ‹œν•  수 있게 λ˜λŠ”λ°μš”
ꡬ간을 μΆ”κ°€ν•  λ•Œ Sectios λ‚΄λΆ€μ—μ„œ 검증이 μ΄λ€„μ Έμ•Όν•˜μ§€ μ•Šμ„κΉŒμš”?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν—› λ§žλ„€μš”γ… γ…  리뷰 λ°˜μ˜ν–ˆμŠ΅λ‹ˆλ‹€~! 덕뢄에 μ½”λ“œκ°€ 훨씬 κΉ”λ”ν•΄μ‘Œλ„€μš” πŸ˜„ 63c094a

Comment on lines 67 to 69
if (!line.getTerminalStationId().equals(stationId)) {
throw new InvalidSectionRequestException("λ§ˆμ§€λ§‰ κ΅¬κ°„λ§Œ μ‚­μ œν•  수 μžˆμŠ΅λ‹ˆλ‹€.");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getterλ₯Ό ν™œμš©ν•΄ λΉ„κ΅ν•˜κΈ° 보닀 lineμ—κ²Œ λ©”μ‹œμ§€λ₯Ό 보내면 μ–΄λ–¨κΉŒμš”?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 λ°˜μ˜ν–ˆμŠ΅λ‹ˆλ‹€γ…Žγ…Ž 63c094a

public class StationResponse {
private final Long id;
private final String name;
public record StationResponse(Long id, String name) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ‹€λ₯Έ DTO와 λ‹€λ₯΄κ²Œ recordλ₯Ό μ‚¬μš©ν•˜μ‹  μ΄μœ κ°€ κΆκΈˆν•©λ‹ˆλ‹€ πŸ€”

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 μΈν…”λ¦¬μ œμ΄κ°€ μΆ”μ²œν•΄μ£ΌκΈΈλž˜ ν˜ΈκΈ°μ‹¬μ— ν•œ 번 μ¨λ΄€μŠ΅λ‹ˆλ‹€ πŸ˜†

Comment on lines 10 to 12
List<Section> findAllByLine_Id(Long lineId);

Optional<Section> findByLine_IdAndDownStation_Id(Long lineId, Long downStationId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ©”μ„œλ“œλͺ… μ»¨λ²€μ…˜μ΄ λ§žμ§€ μ•Šμ€ 것 κ°™μ•„μš” 😒

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCaseκ°€ μ•„λ‹ˆκΈ°λŠ” ν•œλ° μžλ™μ™„μ„± μΆ”μ²œ 이름에 _κ°€ 있고, 가독성이 쑰금 μ’‹μ•„μ§€λŠ” 츑면도 μžˆλŠ” 것 κ°™μ•„μ„œ κ·ΈλŒ€λ‘œ μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.
μ œκ°€ μ‹€λ¬΄μ—μ„œλŠ” 주둜 λ§ˆμ΄λ°”ν‹°μŠ€λ₯Ό μ‚¬μš©ν•˜μ—¬ 잘 λͺ¨λ₯΄λŠ”데 보톡은 camelCaseλ₯Ό μ‚¬μš©ν•˜λ‚˜μš”?
(querydsl λ©”μ„œλ“œλ‚˜ λ‹€λ₯Έ λ©”μ„œλ“œμ™€ 톡일성을 μƒκ°ν•˜λ©΄ 그게 λ§žλŠ” κ±° 같기도 ν•˜λ„€μš”γ…Žγ…Ž)

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional<Section> findByLineIdAndDownStationId(Long lineId, Long downStationId);처럼 κ³ μΉ˜λ‹ˆκΉŒ Unable to locate Attribute with the the given name [downStationId] on this ManagedType [subway.common.BaseEntity] μ—λŸ¬κ°€ λ°œμƒν•˜λŠ” λ¬Έμ œλ„ μžˆλ„€μš”. _κ°€ μ—†μœΌλ©΄ Station downStation λ‚΄λΆ€μ˜ id둜 인식을 λͺ»ν•˜λŠ” 것 κ°™μ•„μš”. 😒

Comment on lines 48 to 55
Section section = Section.builder()
.line(line)
.upStation(upStation)
.downStation(downStation)
.distance(createSectionRequest.getDistance())
.build();

Section savedSection = sectionRepository.save(section);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line#addSection λ₯Ό ν™œμš©ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 λ°˜μ˜ν–ˆμŠ΅λ‹ˆλ‹€~ 63c094a

Comment on lines 55 to 56
assertThat(getResponse.jsonPath().getList("upStationId", Long.class)).containsAnyOf(μ‹ λΆ„λ‹Ήμ„ _ν•˜ν–‰μ’…μ μ—­_ID);
assertThat(getResponse.jsonPath().getList("downStationId", Long.class)).containsAnyOf(μ‹ λΆ„λ‹Ήμ„ _μ‹ κ·œμ—­_ID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ‹ κ·œ ν•˜ν–‰ 쒅점역을 μΆ”κ°€ν•œ 경우 μ‹ κ·œμ—­μ΄ ꡬ간에 ν¬ν•¨λ˜μ–΄ μžˆλ‹€λŠ” 것보닀 ν•˜ν–‰ μ’…μ μ—­μž„μ„ κ²€μ¦ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?
containsExactly λ₯Ό ν™œμš©ν•΄μ„œ μ—­ λͺ©λ‘ μˆœμ„œλ₯Ό κ²€μ¦ν•˜λ©΄ 쒋을 것 같은데 μ–΄λ–»κ²Œ μƒκ°ν•˜μ‹œλ‚˜μš”?

Copy link
Author

@janeljs janeljs Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertThat(getResponse.jsonPath().getList("upStationId", Long.class)).containsExactly(μ‹ λΆ„λ‹Ήμ„ _상행쒅점역_ID, μ‹ λΆ„λ‹Ήμ„ _ν•˜ν–‰μ’…μ μ—­_ID);
assertThat(getResponse.jsonPath().getList("downStationId", Long.class)).containsExactly(μ‹ λΆ„λ‹Ήμ„ _ν•˜ν–‰μ’…μ μ—­_ID, μ‹ λΆ„λ‹Ήμ„ _μ‹ κ·œμ—­_ID);
assertThat(getResponse.jsonPath().getList("distance")).containsExactly(10, 5);

λ§μ”€ν•˜μ‹ λŒ€λ‘œ μœ„μ²˜λŸΌ μž‘μ„±ν•΄λ³΄μ•˜λŠ”λ° μ΄ν•΄ν•˜λ €λ©΄ 3초 정도 버퍼링이 κ±Έλ¦¬λŠ” 것 같기도 ν•΄μ„œ μ•„μ˜ˆ μƒˆλ‘œ μƒμ„±λœ κ΅¬κ°„λ§Œ isEqualTo()둜 κ²€μ¦ν•˜λ„λ‘ μˆ˜μ •ν•΄λ³΄μ•˜μŠ΅λ‹ˆλ‹€! eb8b58c

assertThat(sectionResponse.getUpStationId()).isEqualTo(μ‹ λΆ„λ‹Ήμ„ _ν•˜ν–‰μ’…μ μ—­_ID);
assertThat(sectionResponse.getDownStationId()).isEqualTo(μ‹ λΆ„λ‹Ήμ„ _μ‹ κ·œμ—­_ID);
assertThat(sectionResponse.getDistance()).isEqualTo(5);

Comment on lines 60 to 62
@Nested
@DisplayName("μƒˆλ‘œμš΄ ꡬ간 등둝 μ‹€νŒ¨")
class CreateSectionWithInvalidRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ˜ˆμ™Έ ν…ŒμŠ€νŠΈ πŸ‘

@janeljs janeljs requested a review from testrace July 30, 2023 08:00
Copy link
Member

@testrace testrace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ•ˆλ…•ν•˜μ„Έμš” μ§€μ„ λ‹˜ πŸ˜ƒ
ν”Όλ“œλ°± 반영 μž˜ν•΄μ£Όμ…¨λ„€μš” πŸ‘
μ§€λ‚œ μ½”λ©˜νŠΈμ—μ„œ μ„€λͺ…이 λΆ€μ‘±ν•œ 뢀뢄이 μžˆλŠ” 것 κ°™μ•„ μΆ”κ°€ μ½”λ©˜νŠΈ λ‚¨κ²ΌμŠ΅λ‹ˆλ‹€
확인해 μ£Όμ‹œκ³  λ‹€μ‹œ 리뷰 μš”μ²­ λΆ€νƒλ“œλ €μš”

Comment on lines +35 to +42
public void add(Section section) {
if (!sections.isEmpty()) {
validateUpStationId(section);
validateDownStationId(section);
validateDistance(section);
}

sections.add(section);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ꡬ간 등둝 κΈ°λŠ₯처럼 ꡬ간 제거 λ©”μ„œλ“œλ„ μΆ”κ°€ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 λ°˜μ˜ν–ˆμŠ΅λ‹ˆλ‹€!γ…Žγ…Ž eb1ecaf

}

public List<SectionResponse> findSections(Long lineId) {
List<Section> sections = sectionRepository.findAllByLine_Id(lineId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

노선에 ν¬ν•¨λœ ꡬ간듀을 line 객체λ₯Ό ν™œμš©ν•΄μ„œ κ°€μ Έμ˜¬ μˆ˜κ°€ μžˆλŠ”λ°μš”
sectionRepository λŒ€μ‹  line 객체λ₯Ό ν™œμš©ν•΄μ„œ ꡬ간 λͺ©λ‘μ„ μ‘°νšŒν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

Suggested change
List<Section> sections = sectionRepository.findAllByLine_Id(lineId);
Line line = findLineById(lineId);
List<Section> sections = line.getSections();

Comment on lines 101 to 120
public void deleteSection(Long lineId, Long stationId) {
Line line = findLineById(lineId);

if (line.hasLessThanTwoSections()) {
throw new InvalidSectionRequestException("ꡬ간이 2개 이상일 λ•Œλ§Œ μ‚­μ œν•  수 μžˆμŠ΅λ‹ˆλ‹€.");
}

if (!line.isTerminalStationId(stationId)) {
throw new InvalidSectionRequestException("λ§ˆμ§€λ§‰ κ΅¬κ°„λ§Œ μ‚­μ œν•  수 μžˆμŠ΅λ‹ˆλ‹€.");
}

Section section = sectionRepository.findByLine_IdAndDownStation_Id(lineId, stationId)
.orElseThrow(() -> new NotFoundException(
Map.of(
"lineId", lineId.toString(),
"stationId", stationId.toString()
)));

sectionRepository.delete(section);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addSection λ©”μ„œλ“œμ²˜λŸΌ line 을 μ‘°νšŒν•œ 후에 λ©”μ‹œμ§€λ₯Ό λ³΄λ‚΄μ„œ ꡬ간을 μ‚­μ œν•˜λ©΄ μ–΄λ–¨κΉŒμš”?
μ‚­μ œ κΈ°λŠ₯μ΄λ‹ˆ @Transactional도 μΆ”κ°€λ˜λ©΄ 쒋을 것 κ°™μ•„μš”
line.deleteSection(stationId);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 λ°˜μ˜ν–ˆμŠ΅λ‹ˆλ‹€!γ…Žγ…Ž eb1ecaf

Comment on lines +57 to +59
assertThat(sectionResponse.getUpStationId()).isEqualTo(μ‹ λΆ„λ‹Ήμ„ _ν•˜ν–‰μ’…μ μ—­_ID);
assertThat(sectionResponse.getDownStationId()).isEqualTo(μ‹ λΆ„λ‹Ήμ„ _μ‹ κ·œμ—­_ID);
assertThat(sectionResponse.getDistance()).isEqualTo(5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사싀 λ³€κ²½ μ „κ³Ό λ‹€λ₯΄μ§€ μ•Šλ‹€κ³  μƒκ°λ“€μ–΄μš” πŸ˜…
인수 ν…ŒμŠ€νŠΈλŠ” λΈ”λž™λ°•μŠ€ ν…ŒμŠ€νŠΈμ΄λ‹ˆ ν•˜λ‚˜ ν•˜λ‚˜μ˜ ꡬ간이 μ–΄λ–»κ²Œ κ΅¬μ„±λ˜μ—ˆλŠ”μ§€ 관심 있기 보닀
ꡬ간이 μΆ”κ°€λ˜μ—ˆμ„ λ•Œ 노선이 κ°€μ§€λŠ” 전체 μ—­ λͺ©λ‘μ΄ μ›ν•˜λŠ”λŒ€λ‘œ(μˆœμ„œλŒ€λ‘œ) κ΅¬μ„±λ˜μ—ˆλŠ”μ§€κ°€ 더 관심이 크닀고 μƒκ°ν•΄μ„œ ν”Όλ“œλ°± λ“œλ Έμ—ˆλŠ”λ°μš”
노선에 A-B-C 역이 μžˆμ„ λ•Œ ν•˜ν–‰μ—­(C-D ꡬ간)을 μΆ”κ°€ν•˜λ©΄ λ…Έμ„ μ˜ 전체 μ—­ λͺ©λ‘μ„ A-B-C-Dκ°€ λ˜μ—ˆμŒμ„ κ²€μ¦ν•˜λ©΄
인수 ν…ŒμŠ€νŠΈλ₯Ό μ½λŠ” μž…μž₯μ—μ„œ ꡬ간 μΆ”κ°€ κΈ°λŠ₯을 λΉ λ₯΄κ²Œ νŒŒμ•…ν•  수 μžˆμ„ 것 κ°™μ•„μš”

@@ -21,6 +21,7 @@ public class Line extends BaseEntity {
@Column(length = 20, nullable = false)
private String name;

@Setter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setterλ₯Ό μ œκ³΅ν•˜κΈ° 보닀 update or modify λ©”μ„œλ“œλ₯Ό μ œκ³΅ν•˜κ³ 
λ©”μ„œλ“œ λ‚΄λΆ€μ—μ„œ 값을 μˆ˜μ •ν•˜λ„λ‘ ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

Comment on lines +64 to +65
setIfNotNull(modifyLineRequest.getName(), line::setName);
setIfNotNull(modifyLineRequest.getColor(), line::setColor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setIfNotNull λ©”μ„œλ“œλ₯Ό κ±°μΉ˜μ§€ μ•Šκ³  line 의 값을 λ³€κ²½ν•˜λ©΄ λ„λ©”μΈμ˜ μ œμ•½μ‚¬ν•­μ΄ μ§€μΌœμ§€μ§€ μ•Šμ„ 것 κ°™μ•„μš”
null 체크λ₯Ό line λ‚΄λΆ€μ—μ„œ κ²€μ¦ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants