-
Notifications
You must be signed in to change notification settings - Fork 1
feat : 버스 버저닝 V2 updated_at 추가 #446
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
364aad3
feat : 버스 timetable v2 추가
Choon0414 785a6aa
Merge branch 'refs/heads/develop' into feature/405-bus-timetable-v2
Choon0414 d99a44d
feat : 버스 버저닝 timetable/v2 서비스 구현
Choon0414 6a9ffe7
Merge branch 'refs/heads/develop' into feature/405-bus-timetable-v2
Choon0414 86b7ef0
test : 버스 시간표 조회 v2 테스트 추가
Choon0414 1e541ed
Merge branch 'refs/heads/develop' into feature/405-bus-timetable-v2
Choon0414 200d82e
chore : 버스 v2 테스트 수정
Choon0414 b1a3967
chore : 사용하지 않는 import 제거
Choon0414 bfc6c4e
chore : log() 제거
Choon0414 8a9db2b
chore : 스웨거 설명 추가
Choon0414 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/in/koreatech/koin/domain/bus/dto/BusTimetableResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package in.koreatech.koin.domain.bus.dto; | ||
|
||
import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import in.koreatech.koin.domain.bus.model.BusTimetable; | ||
|
||
@JsonNaming(SnakeCaseStrategy.class) | ||
public record BusTimetableResponse( | ||
List<? extends BusTimetable> busTimetable, | ||
LocalDateTime updatedAt | ||
) { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import in.koreatech.koin.domain.bus.repository.ExpressBusCacheRepository; | ||
import in.koreatech.koin.domain.version.model.Version; | ||
import in.koreatech.koin.domain.version.repository.VersionRepository; | ||
import in.koreatech.koin.domain.version.service.VersionService; | ||
import in.koreatech.koin.support.JsonAssertions; | ||
import io.restassured.RestAssured; | ||
import io.restassured.response.ExtractableResponse; | ||
|
@@ -59,6 +60,9 @@ class BusApiTest extends AcceptanceTest { | |
@Autowired | ||
private ExpressBusCacheRepository expressBusCacheRepository; | ||
|
||
@Autowired | ||
private VersionService versionService; | ||
|
||
private final Instant UPDATED_AT = ZonedDateTime.parse( | ||
"2024-02-21 18:00:00 KST", | ||
ofPattern("yyyy-MM-dd " + "HH:mm:ss z") | ||
|
@@ -137,11 +141,11 @@ void getNextShuttleBusRemainTime() { | |
softly -> { | ||
softly.assertThat(response.body().jsonPath().getString("bus_type")) | ||
.isEqualTo(busType.name().toLowerCase()); | ||
softly.assertThat((Long) response.body().jsonPath().get("now_bus.bus_number")).isNull(); | ||
softly.assertThat((Long)response.body().jsonPath().get("now_bus.bus_number")).isNull(); | ||
softly.assertThat(response.body().jsonPath().getLong("now_bus.remain_time")).isEqualTo( | ||
BusRemainTime.from(arrivalTime).getRemainSeconds(clock)); | ||
softly.assertThat((Long) response.body().jsonPath().get("next_bus.bus_number")).isNull(); | ||
softly.assertThat((Long) response.body().jsonPath().get("next_bus.remain_time")).isNull(); | ||
softly.assertThat((Long)response.body().jsonPath().get("next_bus.bus_number")).isNull(); | ||
softly.assertThat((Long)response.body().jsonPath().get("next_bus.remain_time")).isNull(); | ||
} | ||
); | ||
} | ||
|
@@ -200,8 +204,8 @@ void getNextCityBusRemainTimeRedis() { | |
softly -> { | ||
softly.assertThat(response.body().jsonPath().getString("bus_type")) | ||
.isEqualTo(busType.name().toLowerCase()); | ||
softly.assertThat((Long) response.body().jsonPath().getLong("now_bus.bus_number")).isEqualTo(busNumber); | ||
softly.assertThat((Long) response.body().jsonPath().getLong("now_bus.remain_time")) | ||
softly.assertThat((Long)response.body().jsonPath().getLong("now_bus.bus_number")).isEqualTo(busNumber); | ||
softly.assertThat((Long)response.body().jsonPath().getLong("now_bus.remain_time")) | ||
.isEqualTo( | ||
BusRemainTime.of(remainTime, version.getUpdatedAt().toLocalTime()).getRemainSeconds(clock)); | ||
softly.assertThat(response.body().jsonPath().getObject("next_bus.bus_number", Long.class)).isNull(); | ||
|
@@ -303,12 +307,12 @@ void getNextCityBusRemainTimeOpenApi() { | |
softly -> { | ||
softly.assertThat(response.body().jsonPath().getString("bus_type")) | ||
.isEqualTo(busType.name().toLowerCase()); | ||
softly.assertThat((Long) response.body().jsonPath().getLong("now_bus.bus_number")).isEqualTo(400); | ||
softly.assertThat((Long) response.body().jsonPath().getLong("now_bus.remain_time")) | ||
softly.assertThat((Long)response.body().jsonPath().getLong("now_bus.bus_number")).isEqualTo(400); | ||
softly.assertThat((Long)response.body().jsonPath().getLong("now_bus.remain_time")) | ||
.isEqualTo( | ||
BusRemainTime.of(600L, version.getUpdatedAt().toLocalTime()).getRemainSeconds(clock)); | ||
softly.assertThat((Long) response.body().jsonPath().getLong("next_bus.bus_number")).isEqualTo(405); | ||
softly.assertThat((Long) response.body().jsonPath().getLong("next_bus.remain_time")) | ||
softly.assertThat((Long)response.body().jsonPath().getLong("next_bus.bus_number")).isEqualTo(405); | ||
softly.assertThat((Long)response.body().jsonPath().getLong("next_bus.remain_time")) | ||
.isEqualTo( | ||
BusRemainTime.of(800L, version.getUpdatedAt().toLocalTime()).getRemainSeconds(clock)); | ||
} | ||
|
@@ -441,6 +445,7 @@ void getShuttleBusTimetable() { | |
.param("region", region) | ||
.get("/bus/timetable") | ||
.then() | ||
.log().all() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요거 지워야될것 같아요! |
||
.statusCode(HttpStatus.OK.value()) | ||
.extract(); | ||
|
||
|
@@ -470,4 +475,61 @@ void getShuttleBusTimetable() { | |
] | ||
"""); | ||
} | ||
|
||
@Test | ||
@DisplayName("셔틀버스 시간표를 조회한다(업데이트 시각 포함).") | ||
void getShuttleBusTimetableWithUpdatedAt() { | ||
when(dateTimeProvider.getNow()).thenReturn(Optional.of(UPDATED_AT)); | ||
|
||
Version version = Version.builder() | ||
.version("20240_1712920946") | ||
.type("shuttle_bus_timetable") | ||
.build(); | ||
versionRepository.save(version); | ||
|
||
BusType busType = BusType.from("shuttle"); | ||
String direction = "from"; | ||
String region = "천안"; | ||
|
||
ExtractableResponse<Response> response = RestAssured | ||
.given() | ||
.when() | ||
.param("bus_type", busType.name().toLowerCase()) | ||
.param("direction", direction) | ||
.param("region", region) | ||
.get("/bus/timetable/v2") | ||
.then() | ||
.log().all() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이친구도!! |
||
.statusCode(HttpStatus.OK.value()) | ||
.extract(); | ||
|
||
JsonAssertions.assertThat(response.asPrettyString()) | ||
.isEqualTo(String.format(""" | ||
{ | ||
"bus_timetable": [ | ||
{ | ||
"route_name": "주중", | ||
"arrival_info": [ | ||
{ | ||
"nodeName": "한기대", | ||
"arrivalTime": "18:10" | ||
}, | ||
{ | ||
"nodeName": "신계초,운전리,연춘리", | ||
"arrivalTime": "정차" | ||
}, | ||
{ | ||
"nodeName": "천안역(학화호두과자)", | ||
"arrivalTime": "18:50" | ||
},{ | ||
"nodeName": "터미널(신세계 앞 횡단보도)", | ||
"arrivalTime": "18:55" | ||
} | ||
] | ||
} | ||
], | ||
"updated_at": %s | ||
} | ||
""", version.getUpdatedAt())); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A
개행과 스웨거 설명까지 달아주면 좋을 것 같아요!