diff --git a/src/main/java/wooteco/subway/admin/controller/GlobalExceptionHandler.java b/src/main/java/wooteco/subway/admin/controller/GlobalExceptionHandler.java index 3c56c216a..3b6f0d975 100644 --- a/src/main/java/wooteco/subway/admin/controller/GlobalExceptionHandler.java +++ b/src/main/java/wooteco/subway/admin/controller/GlobalExceptionHandler.java @@ -1,8 +1,12 @@ package wooteco.subway.admin.controller; +import java.util.stream.Collectors; + +import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.dao.DataAccessException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.BindingResult; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -13,8 +17,18 @@ @RestControllerAdvice public class GlobalExceptionHandler { - @ExceptionHandler(value = {MethodArgumentNotValidException.class, BusinessException.class}) - public ResponseEntity bindingErrorHandler(RuntimeException e) { + @ExceptionHandler(value = MethodArgumentNotValidException.class) + public ResponseEntity validExceptionHandler(MethodArgumentNotValidException e) { + BindingResult bindingResult = e.getBindingResult(); + String errorMessage = bindingResult.getAllErrors() + .stream() + .map(DefaultMessageSourceResolvable::getDefaultMessage) + .collect(Collectors.joining("\n")); + return ResponseEntity.badRequest().body(new ErrorResponse(errorMessage)); + } + + @ExceptionHandler(value = BusinessException.class) + public ResponseEntity bindingErrorHandler(BusinessException e) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new ErrorResponse(e.getMessage())); } @@ -24,4 +38,10 @@ public ResponseEntity bindingErrorHandler(DataAccessException e) return ResponseEntity.status(HttpStatus.NOT_FOUND) .body(new ErrorResponse(e.getMessage())); } + + @ExceptionHandler(value = Exception.class) + public ResponseEntity defaultExceptionHandler(Exception e) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(new ErrorResponse(e.getMessage())); + } } diff --git a/src/main/java/wooteco/subway/admin/domain/CreateTime.java b/src/main/java/wooteco/subway/admin/domain/CreateTime.java index a4d0d8d00..e5818b906 100644 --- a/src/main/java/wooteco/subway/admin/domain/CreateTime.java +++ b/src/main/java/wooteco/subway/admin/domain/CreateTime.java @@ -3,7 +3,6 @@ import java.time.LocalDateTime; import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedDate; public abstract class CreateTime { diff --git a/src/main/java/wooteco/subway/admin/service/GraphService.java b/src/main/java/wooteco/subway/admin/domain/Graph.java similarity index 78% rename from src/main/java/wooteco/subway/admin/service/GraphService.java rename to src/main/java/wooteco/subway/admin/domain/Graph.java index ac9a99307..742fd8b81 100644 --- a/src/main/java/wooteco/subway/admin/service/GraphService.java +++ b/src/main/java/wooteco/subway/admin/domain/Graph.java @@ -1,46 +1,35 @@ -package wooteco.subway.admin.service; +package wooteco.subway.admin.domain; import java.util.List; import java.util.Objects; import org.jgrapht.alg.shortestpath.DijkstraShortestPath; import org.jgrapht.graph.WeightedMultigraph; -import org.springframework.stereotype.Service; -import wooteco.subway.admin.domain.Line; import wooteco.subway.admin.dto.GraphResponse; import wooteco.subway.admin.dto.PathType; import wooteco.subway.admin.exception.IllegalStationNameException; import wooteco.subway.admin.exception.NotFoundLineException; import wooteco.subway.admin.exception.NotFoundPathException; -@Service -public class GraphService { - public GraphResponse findPath(List lines, Long sourceId, Long targetId, - PathType pathType) { - validate(lines, sourceId, targetId); - WeightedMultigraph graph = mapLinesToGraph(lines, pathType); - DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath<>( - graph); +public class Graph { - if (Objects.isNull(dijkstraShortestPath.getPath(sourceId, targetId))) { - throw new NotFoundPathException(sourceId, targetId); - } + private final WeightedMultigraph graph; - return mapToGraphResponse(sourceId, targetId, dijkstraShortestPath); + private Graph( + WeightedMultigraph graph) { + this.graph = graph; } - private void validate(List lines, Long sourceId, Long targetId) { - if (Objects.isNull(lines)) { - throw new NotFoundLineException(); - } - if (Objects.equals(sourceId, targetId)) { - throw new IllegalStationNameException(sourceId, targetId); - } + public static Graph of(List lines, PathType pathType) { + return new Graph(mapLinesToGraph(lines, pathType)); } - private WeightedMultigraph mapLinesToGraph(List lines, + private static WeightedMultigraph mapLinesToGraph(List lines, PathType pathType) { + if (Objects.isNull(lines)) { + throw new NotFoundLineException(); + } WeightedMultigraph graph = new WeightedMultigraph(LineStationEdge.class); lines.stream() @@ -55,6 +44,24 @@ private WeightedMultigraph mapLinesToGraph(List lin return graph; } + public GraphResponse findPath(Long sourceId, Long targetId) { + validate(sourceId, targetId); + DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath<>( + graph); + + if (Objects.isNull(dijkstraShortestPath.getPath(sourceId, targetId))) { + throw new NotFoundPathException(sourceId, targetId); + } + + return mapToGraphResponse(sourceId, targetId, dijkstraShortestPath); + } + + private void validate(Long sourceId, Long targetId) { + if (Objects.equals(sourceId, targetId)) { + throw new IllegalStationNameException(sourceId, targetId); + } + } + private GraphResponse mapToGraphResponse(Long source, Long target, DijkstraShortestPath dijkstraShortestPath) { List path = dijkstraShortestPath.getPath(source, target).getVertexList(); diff --git a/src/main/java/wooteco/subway/admin/domain/Line.java b/src/main/java/wooteco/subway/admin/domain/Line.java index 309c5f637..20faa1584 100644 --- a/src/main/java/wooteco/subway/admin/domain/Line.java +++ b/src/main/java/wooteco/subway/admin/domain/Line.java @@ -12,6 +12,7 @@ import org.springframework.data.annotation.Id; public class Line extends UpdateTime { + @Id private Long id; private String name; diff --git a/src/main/java/wooteco/subway/admin/domain/LineStation.java b/src/main/java/wooteco/subway/admin/domain/LineStation.java index 21165368c..7f51f6254 100644 --- a/src/main/java/wooteco/subway/admin/domain/LineStation.java +++ b/src/main/java/wooteco/subway/admin/domain/LineStation.java @@ -2,9 +2,9 @@ public class LineStation { private Long preStationId; - private Long stationId; - private int distance; - private int duration; + private final Long stationId; + private final int distance; + private final int duration; public LineStation(Long preStationId, Long stationId, int distance, int duration) { this.preStationId = preStationId; diff --git a/src/main/java/wooteco/subway/admin/service/LineStationEdge.java b/src/main/java/wooteco/subway/admin/domain/LineStationEdge.java similarity index 78% rename from src/main/java/wooteco/subway/admin/service/LineStationEdge.java rename to src/main/java/wooteco/subway/admin/domain/LineStationEdge.java index bf0b76d71..ed576e657 100644 --- a/src/main/java/wooteco/subway/admin/service/LineStationEdge.java +++ b/src/main/java/wooteco/subway/admin/domain/LineStationEdge.java @@ -1,14 +1,13 @@ -package wooteco.subway.admin.service; +package wooteco.subway.admin.domain; import org.jgrapht.graph.DefaultWeightedEdge; -import wooteco.subway.admin.domain.LineStation; import wooteco.subway.admin.dto.PathType; public class LineStationEdge extends DefaultWeightedEdge { - private LineStation lineStation; - private PathType pathType; + private final LineStation lineStation; + private final PathType pathType; public LineStationEdge(LineStation lineStation, PathType pathType) { this.lineStation = lineStation; diff --git a/src/main/java/wooteco/subway/admin/domain/Station.java b/src/main/java/wooteco/subway/admin/domain/Station.java index c9269a313..5b6c602cc 100644 --- a/src/main/java/wooteco/subway/admin/domain/Station.java +++ b/src/main/java/wooteco/subway/admin/domain/Station.java @@ -3,6 +3,7 @@ import org.springframework.data.annotation.Id; public class Station extends CreateTime { + @Id private Long id; private String name; diff --git a/src/main/java/wooteco/subway/admin/domain/UpdateTime.java b/src/main/java/wooteco/subway/admin/domain/UpdateTime.java index acb72d448..152bf2899 100644 --- a/src/main/java/wooteco/subway/admin/domain/UpdateTime.java +++ b/src/main/java/wooteco/subway/admin/domain/UpdateTime.java @@ -4,13 +4,12 @@ import org.springframework.data.annotation.LastModifiedDate; -public abstract class UpdateTime extends CreateTime{ +public abstract class UpdateTime extends CreateTime { @LastModifiedDate private LocalDateTime updatedAt; - - public UpdateTime(){ + public UpdateTime() { } public UpdateTime(LocalDateTime updatedAt) { diff --git a/src/main/java/wooteco/subway/admin/dto/ErrorResponse.java b/src/main/java/wooteco/subway/admin/dto/ErrorResponse.java index 1f506d5c7..754c3c249 100644 --- a/src/main/java/wooteco/subway/admin/dto/ErrorResponse.java +++ b/src/main/java/wooteco/subway/admin/dto/ErrorResponse.java @@ -1,6 +1,5 @@ package wooteco.subway.admin.dto; - public class ErrorResponse { private String errorMessage; diff --git a/src/main/java/wooteco/subway/admin/dto/LineDetailResponse.java b/src/main/java/wooteco/subway/admin/dto/LineDetailResponse.java index cd73a695c..08068efff 100644 --- a/src/main/java/wooteco/subway/admin/dto/LineDetailResponse.java +++ b/src/main/java/wooteco/subway/admin/dto/LineDetailResponse.java @@ -1,13 +1,11 @@ package wooteco.subway.admin.dto; -import wooteco.subway.admin.domain.Line; -import wooteco.subway.admin.domain.Station; - import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; + +import wooteco.subway.admin.domain.Line; +import wooteco.subway.admin.domain.Station; public class LineDetailResponse { private Long id; @@ -38,10 +36,11 @@ public LineDetailResponse(Long id, String name, String backgroundColor, } public static LineDetailResponse of(Line line, List stations) { - return new LineDetailResponse(line.getId(), line.getName(), line.getBackgroundColor(), line.getStartTime(), line.getEndTime(), line.getIntervalTime(), line.getCreatedAt(), line.getUpdatedAt(), stations); + return new LineDetailResponse(line.getId(), line.getName(), line.getBackgroundColor(), + line.getStartTime(), line.getEndTime(), line.getIntervalTime(), line.getCreatedAt(), + line.getUpdatedAt(), stations); } - public Long getId() { return id; } diff --git a/src/main/java/wooteco/subway/admin/dto/LineRequest.java b/src/main/java/wooteco/subway/admin/dto/LineRequest.java index b35a9f68b..8ab7edbf5 100644 --- a/src/main/java/wooteco/subway/admin/dto/LineRequest.java +++ b/src/main/java/wooteco/subway/admin/dto/LineRequest.java @@ -1,14 +1,13 @@ package wooteco.subway.admin.dto; -import wooteco.subway.admin.domain.Line; - import java.time.LocalTime; -import java.util.ArrayList; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import wooteco.subway.admin.domain.Line; + public class LineRequest { @NotBlank(message = "노선 이름은 필수 입력 요소입니다.") diff --git a/src/main/java/wooteco/subway/admin/dto/PathRequest.java b/src/main/java/wooteco/subway/admin/dto/PathRequest.java index 044ec5a77..3fffd13bc 100644 --- a/src/main/java/wooteco/subway/admin/dto/PathRequest.java +++ b/src/main/java/wooteco/subway/admin/dto/PathRequest.java @@ -3,6 +3,7 @@ import javax.validation.constraints.NotBlank; public class PathRequest { + @NotBlank(message = "이전 역 이름은 필수 입력 요소입니다.") private String sourceName; @NotBlank(message = "대상 역 이름은 필수 입력 요소입니다.") diff --git a/src/main/java/wooteco/subway/admin/dto/StationCreateRequest.java b/src/main/java/wooteco/subway/admin/dto/StationCreateRequest.java index 33b782987..a3958f9cc 100644 --- a/src/main/java/wooteco/subway/admin/dto/StationCreateRequest.java +++ b/src/main/java/wooteco/subway/admin/dto/StationCreateRequest.java @@ -1,6 +1,5 @@ package wooteco.subway.admin.dto; - import javax.validation.constraints.NotBlank; import wooteco.subway.admin.domain.Station; diff --git a/src/main/java/wooteco/subway/admin/dto/StationResponse.java b/src/main/java/wooteco/subway/admin/dto/StationResponse.java index b8e1ffc88..48d4804fd 100644 --- a/src/main/java/wooteco/subway/admin/dto/StationResponse.java +++ b/src/main/java/wooteco/subway/admin/dto/StationResponse.java @@ -1,11 +1,11 @@ package wooteco.subway.admin.dto; -import wooteco.subway.admin.domain.Station; - import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; +import wooteco.subway.admin.domain.Station; + public class StationResponse { private Long id; private String name; @@ -17,8 +17,8 @@ public static StationResponse of(Station station) { public static List listOf(List stations) { return stations.stream() - .map(StationResponse::of) - .collect(Collectors.toList()); + .map(StationResponse::of) + .collect(Collectors.toList()); } public StationResponse() { diff --git a/src/main/java/wooteco/subway/admin/dto/WholeSubwayResponse.java b/src/main/java/wooteco/subway/admin/dto/WholeSubwayResponse.java index 1190fadeb..95424aa43 100644 --- a/src/main/java/wooteco/subway/admin/dto/WholeSubwayResponse.java +++ b/src/main/java/wooteco/subway/admin/dto/WholeSubwayResponse.java @@ -1,7 +1,6 @@ package wooteco.subway.admin.dto; import java.util.List; -import java.util.Map; public class WholeSubwayResponse { private List lineDetailResponse; diff --git a/src/main/java/wooteco/subway/admin/exception/IllegalTypeNameException.java b/src/main/java/wooteco/subway/admin/exception/IllegalTypeNameException.java index ebb2af735..cd97663f2 100644 --- a/src/main/java/wooteco/subway/admin/exception/IllegalTypeNameException.java +++ b/src/main/java/wooteco/subway/admin/exception/IllegalTypeNameException.java @@ -3,6 +3,6 @@ public class IllegalTypeNameException extends BusinessException { public IllegalTypeNameException(String typeName) { - super(typeName +"방식의 경로는 지원하지 않습니다."); + super(typeName + "방식의 경로는 지원하지 않습니다."); } } diff --git a/src/main/java/wooteco/subway/admin/repository/LineRepository.java b/src/main/java/wooteco/subway/admin/repository/LineRepository.java index 83ddc5790..a1e7ceca0 100644 --- a/src/main/java/wooteco/subway/admin/repository/LineRepository.java +++ b/src/main/java/wooteco/subway/admin/repository/LineRepository.java @@ -1,9 +1,10 @@ package wooteco.subway.admin.repository; +import java.util.List; + import org.springframework.data.repository.CrudRepository; -import wooteco.subway.admin.domain.Line; -import java.util.List; +import wooteco.subway.admin.domain.Line; public interface LineRepository extends CrudRepository { @Override diff --git a/src/main/java/wooteco/subway/admin/repository/StationRepository.java b/src/main/java/wooteco/subway/admin/repository/StationRepository.java index 5cb66563f..d72ff4349 100644 --- a/src/main/java/wooteco/subway/admin/repository/StationRepository.java +++ b/src/main/java/wooteco/subway/admin/repository/StationRepository.java @@ -1,12 +1,13 @@ package wooteco.subway.admin.repository; +import java.util.List; +import java.util.Optional; + import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; -import wooteco.subway.admin.domain.Station; -import java.util.List; -import java.util.Optional; +import wooteco.subway.admin.domain.Station; public interface StationRepository extends CrudRepository { @Override diff --git a/src/main/java/wooteco/subway/admin/service/PathService.java b/src/main/java/wooteco/subway/admin/service/PathService.java index d7efc51e0..115569a87 100644 --- a/src/main/java/wooteco/subway/admin/service/PathService.java +++ b/src/main/java/wooteco/subway/admin/service/PathService.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.subway.admin.domain.Graph; import wooteco.subway.admin.domain.Line; import wooteco.subway.admin.dto.GraphResponse; import wooteco.subway.admin.dto.PathRequest; @@ -20,13 +21,10 @@ public class PathService { private final StationService stationService; private final LineService lineService; - private final GraphService graphService; - public PathService(StationService stationService, - LineService lineService, GraphService graphService) { + public PathService(StationService stationService, LineService lineService) { this.stationService = stationService; this.lineService = lineService; - this.graphService = graphService; } public PathResponse findPath(PathRequest request) { @@ -34,8 +32,9 @@ public PathResponse findPath(PathRequest request) { Long targetId = stationService.findIdByName(request.getTargetName()); List lines = lineService.findAll(); - GraphResponse graphResponse = graphService.findPath(lines, sourceId, targetId, - PathType.of(request.getType())); + Graph graph = Graph.of(lines, PathType.of(request.getType())); + GraphResponse graphResponse = graph.findPath(sourceId, targetId); + List path = graphResponse.getPath(); List stationResponses = StationResponse.listOf( diff --git a/src/main/resources/static/admin/js/views/AdminEdge.js b/src/main/resources/static/admin/js/views/AdminEdge.js index a9f9b2107..7db1da408 100644 --- a/src/main/resources/static/admin/js/views/AdminEdge.js +++ b/src/main/resources/static/admin/js/views/AdminEdge.js @@ -58,7 +58,7 @@ function AdminEdge() { "afterbegin", subwayLineOptionTemplate ); - }).catch(response => response.json().then(error => alert(error.message))); + }).catch(response => response.json().then(error => alert(error.errorMessage))); }; const onCreateStationHandler = event => { @@ -87,7 +87,7 @@ function AdminEdge() { }, body: JSON.stringify(data) }).then(response => { - if (response.status >= 400) { + if (!response.ok) { throw response; } return response.json(); @@ -113,7 +113,7 @@ function AdminEdge() { edgePadding: 25 }); } - }).catch(response => response.json().then(error => alert(error.message))); + }).catch(response => response.json().then(error => alert(error.errorMessage))); } function validate(data) { @@ -238,7 +238,7 @@ function AdminEdge() { items: 1, edgePadding: 25 }); - }).catch(response => response.json().then(error => alert(error.message))); + }).catch(response => response.json().then(error => alert(error.errorMessage))); }; } diff --git a/src/main/resources/static/admin/js/views/AdminLine.js b/src/main/resources/static/admin/js/views/AdminLine.js index 806813352..80bd65433 100644 --- a/src/main/resources/static/admin/js/views/AdminLine.js +++ b/src/main/resources/static/admin/js/views/AdminLine.js @@ -29,8 +29,12 @@ function AdminLine() { 'Content-Type': 'application/json' }, body: JSON.stringify(data) - }).then(response => response.json()) - .then(jsonResponse => { + }).then(response => { + if (!response.ok) { + throw response + } + return response.json(); + }).then(jsonResponse => { let lines = document.querySelectorAll(".line-id"); for (let line of lines) { if (line.innerText.trim() === updateId) { @@ -38,7 +42,7 @@ function AdminLine() { } } updateId = null; - }); + }).catch(error => error.json()).then(json => alert(json.errorMessage)); } function createLine(data) { @@ -49,13 +53,12 @@ function AdminLine() { }, body: JSON.stringify(data) }).then(response => { - if (response.status >= 400) { - alert("에러가 발생했습니다."); + if (!response.ok) { + throw response; } return response.json(); }) .then(jsonResponse => { - const newSubwayLine = { id: jsonResponse.id, name: jsonResponse.name, @@ -65,7 +68,7 @@ function AdminLine() { "beforeend", subwayLinesTemplate(newSubwayLine) ); - }); + }).catch(error => error.json()).then(error => alert(error.errorMessage)); } const onCreateSubwayLine = event => { @@ -157,14 +160,19 @@ function AdminLine() { headers: { 'Content-Type': 'application/json; charset=utf-8' } - }).then(response => response.json()) + }).then(response => { + if (!response.ok) { + throw response; + } + return response.json(); + }) .then(jsonResponse => { document.querySelector("#first-time-display").innerText = jsonResponse.startTime.toString() .substr(0, 5); document.querySelector("#last-time-display").innerText = jsonResponse.endTime.toString() .substr(0, 5); document.querySelector("#interval-time-display").innerText = jsonResponse.intervalTime + "분"; - }); + }).catch(error => error.json()).then(error => alert(error.errorMessage)); } } @@ -189,14 +197,18 @@ function AdminLine() { headers: { 'Content-type': 'application/json' } - }).then(response => response.json()) + }).then(response => { + if (!response.ok) { + throw response; + } + return response.json(); + }) .then(jsonResponse => { for (const line of jsonResponse) { $subwayLineList.insertAdjacentHTML("beforeend", subwayLinesTemplate(line)); } - }).catch(error => { - alert(error); - }); + }).catch(error => error.json()).then(error => alert(error.errorMessage)); + ; }; diff --git a/src/main/resources/static/admin/js/views/AdminStation.js b/src/main/resources/static/admin/js/views/AdminStation.js index c0ed514a8..f8da4d451 100644 --- a/src/main/resources/static/admin/js/views/AdminStation.js +++ b/src/main/resources/static/admin/js/views/AdminStation.js @@ -29,24 +29,15 @@ function AdminStation() { }, body: JSON.stringify(data) }).then(response => { - if (response.status >= 400) { - alert("에러가 발생했습니다."); - statusCode = 500; + if (!response.ok) { + throw response; } return response.json(); }) .then(response => { - if (statusCode !== 500) { - $stationNameInput.value = ""; - $stationList.insertAdjacentHTML("beforeend", listItemTemplate(response)); - } else { - $errorMessage.innerText = response.message; - } - }).catch(error => { - alert(error); - }); - - + $stationNameInput.value = ""; + $stationList.insertAdjacentHTML("beforeend", listItemTemplate(response)); + }).catch(error => error.json()).then(error => alert(error.errorMessage)); }; function validate(stationName) { diff --git a/src/main/resources/static/service/js/views/Map.js b/src/main/resources/static/service/js/views/Map.js index 63c9870ca..0da4eeda6 100644 --- a/src/main/resources/static/service/js/views/Map.js +++ b/src/main/resources/static/service/js/views/Map.js @@ -22,7 +22,7 @@ function Map() { items: 3, edgePadding: 25 }); - }); + }).catch(error => error.json()).then(error => alert(error.errorMessage)); }; this.init = () => { diff --git a/src/main/resources/static/service/js/views/Search.js b/src/main/resources/static/service/js/views/Search.js index ce34e05bd..4a425e205 100644 --- a/src/main/resources/static/service/js/views/Search.js +++ b/src/main/resources/static/service/js/views/Search.js @@ -50,7 +50,7 @@ function Search() { $target.classList.toggle("border-l", true); $target.classList.toggle("border-t", true); $target.classList.toggle("border-r", true); - $byDistanceButton.classList.toggle("bg-gray-200",true); + $byDistanceButton.classList.toggle("bg-gray-200", true); $byDistanceButton.classList.toggle("border-l", false); $byDistanceButton.classList.toggle("border-t", false); $byDistanceButton.classList.toggle("border-r", false); @@ -86,10 +86,10 @@ function Search() { response.json().then(jsonResponse => { showSearchResult(jsonResponse); }); - }).catch(error => error.json().then(json => { - alert(json.message); - })) - } + }).catch(error => error.json()).then(jsonError => { + alert(jsonError.errorMessage); + }); + }; const onToggleFavorite = event => { event.preventDefault() diff --git a/src/test/java/wooteco/subway/admin/service/PathServiceTest.java b/src/test/java/wooteco/subway/admin/service/PathServiceTest.java index f287f52ab..b992cde71 100644 --- a/src/test/java/wooteco/subway/admin/service/PathServiceTest.java +++ b/src/test/java/wooteco/subway/admin/service/PathServiceTest.java @@ -43,8 +43,6 @@ class PathServiceTest { @Mock private LineService lineService; - private GraphService graphService; - private PathService pathService; private Line line1; @@ -66,8 +64,7 @@ class PathServiceTest { @BeforeEach void setUp() { - graphService = new GraphService(); - pathService = new PathService(stationService, lineService, graphService); + pathService = new PathService(stationService, lineService); station1 = new Station(1L, STATION_NAME1); station2 = new Station(2L, STATION_NAME2);