diff --git a/backend/bang-ggood/src/main/java/com/bang_ggood/station/service/SubwayStationService.java b/backend/bang-ggood/src/main/java/com/bang_ggood/station/service/SubwayStationService.java index 6114a874e..576e6472a 100644 --- a/backend/bang-ggood/src/main/java/com/bang_ggood/station/service/SubwayStationService.java +++ b/backend/bang-ggood/src/main/java/com/bang_ggood/station/service/SubwayStationService.java @@ -11,10 +11,12 @@ public class SubwayStationService { private static final List SUBWAY_STATIONS = SubwayReader.readSubwayStationData(); + private static final int MAX_WALKING_TIME = 30; public SubwayStationResponses readNearestStation(double latitude, double longitude) { List stationResponses = SUBWAY_STATIONS.stream() .map(station -> SubwayStationResponse.of(station, latitude, longitude)) + .filter(response -> response.getWalkingTime() < MAX_WALKING_TIME) .toList(); return SubwayStationResponses.from(stationResponses); diff --git a/backend/bang-ggood/src/test/java/com/bang_ggood/station/service/SubwayStationServiceTest.java b/backend/bang-ggood/src/test/java/com/bang_ggood/station/service/SubwayStationServiceTest.java index e54ca72a8..308b5ba20 100644 --- a/backend/bang-ggood/src/test/java/com/bang_ggood/station/service/SubwayStationServiceTest.java +++ b/backend/bang-ggood/src/test/java/com/bang_ggood/station/service/SubwayStationServiceTest.java @@ -3,6 +3,7 @@ import com.bang_ggood.IntegrationTestSupport; import com.bang_ggood.station.dto.response.SubwayStationResponse; import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -54,6 +55,15 @@ void readNearestStation(double latitude, double longitude, Station nearestStatio ); } + @DisplayName("도보 30분이 넘는 지하철 역은 보여주지 않는다.") + @Test + void readNearestStation_over30Minutes() { + // given & when + List responses = subwayStationService.readNearestStation(0, 0) + .getStations(); + assertThat(responses).hasSize(0); + } + private static class Station { String name; List lines;