Skip to content

Commit

Permalink
feat(pathfinder): 존재하지 않은 출발역이나 도착역을 조회 할 경우 예외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyeom committed Nov 27, 2022
1 parent 15ac7ef commit 4d7ee4c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- [X] 최단 경로 조회 기능 구현하기
- [X] 최단 경로 조회 인수 테스트 작성
- [X] 최단 경로 조회 기능 추가
- [ ] 예외 사항 Validation 기능 구현하기
- [X] 예외 사항 Validation 기능 구현하기
- [X] 출발역과 도착역이 같은 경우
- [X] 인수 테스트 작성
- [X] 도메인 테스트 작성
Expand All @@ -59,7 +59,6 @@
- [X] 인수 테스트 작성
- [X] 도메인 테스트 작성
- [X] Validation 기능 구현
- [ ] 존재하지 않은 출발역이나 도착역을 조회 할 경우
- [ ] 인수 테스트 작성
- [ ] 도메인 테스트 작성
- [ ] Validation 기능 구현
- [X] 존재하지 않은 출발역이나 도착역을 조회 할 경우
- [X] 인수 테스트 작성
- [X] Validation 기능 구현
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,17 @@ void getLinesWithException2() {
// then
최단경로_목록_조회_실패(response);
}

@DisplayName("최단 경로를 조회 시, 존재하지 않은 출발역이나 도착역을 조회 할 경우 예외를 반환한다.")
@Test
void getLinesWithException3() {
// given
long 없는역_ID = 100L;

// when
ExtractableResponse<Response> response = 최단_경로_조회_요청(강남역.getId(), 없는역_ID);

// then
최단경로_목록_조회_실패(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ void getLinesWithException2() {
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("출발역과 도착역이 연결이 되어 있지 않습니다.");
}

@DisplayName("최단 경로를 조회 시, 존재하지 않은 출발역이나 도착역을 조회 할 경우 예외를 반환한다.")
@Test
void getLinesWithException3() {
long 없는역_ID = 100L;
when(stationRepository.findById(강남역.getId())).thenReturn(Optional.of(강남역));
when(stationRepository.findById(없는역_ID)).thenReturn(Optional.empty());

assertThatThrownBy(() -> pathService.findShortestPath(강남역.getId(), 없는역_ID))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("%d", 없는역_ID)
.hasMessageContaining("에 해당하는 Station을 찾을 수 없습니다.");
}
}

0 comments on commit 4d7ee4c

Please sign in to comment.