-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FEAT] 버스 노선, 정류장, 노선정류장 서비스 테스트 추가 #50
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7d0fed8
test: BusRouteService.findById method 테스트 작성
JuneParkCode 2b94724
test : BusRouteService.findByRouteName 테스트 작성
Gyaak 80ee20e
test: BusStationService.findById method 테스트 작성
JuneParkCode 5e9747a
test : BusRouteService.createBusStation 테스트 작성
Gyaak 7db828e
test: BusStationService.findByName method 테스트 작성
JuneParkCode 234808a
test : 테스트를 위한 BusFactory 클래스 정의
Gyaak 198ef86
test : BusRouteStationServiceTest 작성
Gyaak 87b6790
Merge remote-tracking branch 'origin/develop' into feature/#44
Gyaak 2371dd4
test : SecurityConfig 롤백
Gyaak e1c1609
test : SecurityConfig 롤백
Gyaak 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 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
169 changes: 169 additions & 0 deletions
169
server/src/test/java/com/talkka/server/bus/service/BusFactory.java
This file contains 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,169 @@ | ||
package com.talkka.server.bus.service; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import com.talkka.server.bus.dao.BusRouteEntity; | ||
import com.talkka.server.bus.dao.BusRouteStationEntity; | ||
import com.talkka.server.bus.dao.BusStationEntity; | ||
import com.talkka.server.bus.dto.BusRouteCreateDto; | ||
import com.talkka.server.bus.dto.BusRouteRespDto; | ||
import com.talkka.server.bus.dto.BusRouteStationCreateDto; | ||
import com.talkka.server.bus.dto.BusRouteStationRespDto; | ||
import com.talkka.server.bus.dto.BusStationCreateDto; | ||
import com.talkka.server.bus.dto.BusStationRespDto; | ||
import com.talkka.server.bus.enums.BusRouteType; | ||
import com.talkka.server.bus.enums.CenterStation; | ||
import com.talkka.server.bus.enums.DistrictCode; | ||
import com.talkka.server.bus.enums.TurnStation; | ||
|
||
public class BusFactory { | ||
|
||
protected static BusRouteEntity getBusRouteEntity(Long id) { | ||
return BusRouteEntity.builder() | ||
.id(id) | ||
.apiRouteId("BRT" + id) | ||
.routeName("7800" + id) | ||
.routeTypeCd(BusRouteType.DIRECT_SEAT_CITY_BUS) | ||
.routeTypeName(BusRouteType.DIRECT_SEAT_CITY_BUS.getName()) | ||
.companyId("COMP123") | ||
.companyName("수형운수") | ||
.companyTel("02-123-4567") | ||
.districtCd(DistrictCode.DONGDUCHEON) | ||
.upFirstTime("05:30") | ||
.upLastTime("23:00") | ||
.downFirstTime("06:00") | ||
.downLastTime("00:35") | ||
.startMobileNo("101") | ||
.startStationId(1001L) | ||
.startStationName("기점 정류소") | ||
.endStationId(2002L) | ||
.endMobileNo("202") | ||
.endStationName("종점 정류소") | ||
.regionName("서울") | ||
.peekAlloc(15) | ||
.nPeekAlloc(25) | ||
.build(); | ||
} | ||
|
||
protected static BusRouteCreateDto getBusRouteCreateDto(Long id) { | ||
|
||
return BusRouteCreateDto.builder() | ||
.apiRouteId("BRT" + id) | ||
.routeName("7800") | ||
.routeTypeCd(BusRouteType.DIRECT_SEAT_CITY_BUS) | ||
.routeTypeName(BusRouteType.DIRECT_SEAT_CITY_BUS.getName()) | ||
.companyId("COMP123") | ||
.companyName("수형운수") | ||
.companyTel("02-123-4567") | ||
.districtCd(DistrictCode.DONGDUCHEON) | ||
.upFirstTime("05:30") | ||
.upLastTime("23:00") | ||
.downFirstTime("06:00") | ||
.downLastTime("00:35") | ||
.startMobileNo("101") | ||
.startStationId(1001L) | ||
.startStationName("기점 정류소") | ||
.endStationId(2002L) | ||
.endMobileNo("202") | ||
.endStationName("종점 정류소") | ||
.regionName("서울") | ||
.peekAlloc(15) | ||
.nPeekAlloc(25) | ||
.build(); | ||
} | ||
|
||
protected static BusRouteRespDto getBusRouteRespDto(Long id) { | ||
return BusRouteRespDto.builder() | ||
.routeId(id) | ||
.routeName("7800" + id) | ||
.routeTypeCd(BusRouteType.DIRECT_SEAT_CITY_BUS) | ||
.routeTypeName(BusRouteType.DIRECT_SEAT_CITY_BUS.getName()) | ||
.districtCd(DistrictCode.DONGDUCHEON) | ||
.upFirstTime("05:30") | ||
.upLastTime("23:00") | ||
.downFirstTime("06:00") | ||
.downLastTime("00:35") | ||
.startMobileNo("101") | ||
.startStationId(1001L) | ||
.startStationName("기점 정류소") | ||
.endStationId(2002L) | ||
.endMobileNo("202") | ||
.endStationName("종점 정류소") | ||
.regionName("서울") | ||
.peekAlloc(15) | ||
.nPeekAlloc(25) | ||
.build(); | ||
} | ||
|
||
protected static BusStationEntity getBusStationEntity(Long id) { | ||
return BusStationEntity.builder() | ||
.id(id) | ||
.apiStationId("BST" + id) | ||
.stationName("정거장" + id) | ||
.regionName("서울") | ||
.districtCd(DistrictCode.DONGDUCHEON) | ||
.centerYn(CenterStation.CENTER_STATION) | ||
.turnYn(TurnStation.TURN_STATION) | ||
.longitude(BigDecimal.valueOf(127.123456)) | ||
.latitude(BigDecimal.valueOf(37.123456)) | ||
.build(); | ||
} | ||
|
||
protected static BusStationCreateDto getBusStationCreateDto(Long id) { | ||
return BusStationCreateDto.builder() | ||
.apiStationId("BST" + id) | ||
.stationName("정거장" + id) | ||
.regionName("서울") | ||
.districtCd(DistrictCode.DONGDUCHEON) | ||
.centerYn(CenterStation.CENTER_STATION) | ||
.turnYn(TurnStation.TURN_STATION) | ||
.longitude(BigDecimal.valueOf(127.123456)) | ||
.latitude(BigDecimal.valueOf(37.123456)) | ||
.build(); | ||
} | ||
|
||
protected static BusStationRespDto getBusStationRespDto(Long id) { | ||
return BusStationRespDto.builder() | ||
.stationId(id) | ||
.stationName("정거장" + id) | ||
.regionName("서울") | ||
.districtCd(DistrictCode.DONGDUCHEON) | ||
.centerYn(CenterStation.CENTER_STATION) | ||
.turnYn(TurnStation.TURN_STATION) | ||
.longitude(BigDecimal.valueOf(127.123456)) | ||
.latitude(BigDecimal.valueOf(37.123456)) | ||
.build(); | ||
} | ||
|
||
protected static BusRouteStationEntity getBusRouteStationEntity(Long id, BusRouteEntity routeEntity, | ||
BusStationEntity stationEntity) { | ||
return BusRouteStationEntity.builder() | ||
.id(id) | ||
.route(routeEntity) | ||
.station(stationEntity) | ||
.stationName("정거장" + id) | ||
.stationSeq(Short.valueOf(String.valueOf(id))) | ||
.build(); | ||
} | ||
|
||
protected static BusRouteStationCreateDto getBusRouteStationCreateDto(Long id) { | ||
return BusRouteStationCreateDto.builder() | ||
.apiRouteId("BRT" + id) | ||
.apiStationId("BST" + id) | ||
.stationName("정거장" + id) | ||
.stationSeq(Short.valueOf(String.valueOf(id))) | ||
.build(); | ||
} | ||
|
||
protected static BusRouteStationRespDto getBusRouteStationRespDto(Long id, BusRouteRespDto routeRespDto, | ||
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. protected 로 하게된 배경이 궁금합니다 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. bus관련 테스트에서만 사용하는 객체라고 생각해서 protected로 설정했습니다. |
||
BusStationRespDto stationRespDto) { | ||
return BusRouteStationRespDto.builder() | ||
.busRouteStationId(id) | ||
.route(routeRespDto) | ||
.station(stationRespDto) | ||
.stationName("정거장" + id) | ||
.stationSeq(Short.valueOf(String.valueOf(id))) | ||
.build(); | ||
} | ||
|
||
} |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
해당 팩토리는 테스트에서 사용할 객체 생성 factory 두신 것이라고 이해하면 될까요?
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.
네 맞습니다.
BusRouteService, BusStationService, BusRouteStationService가 사용하는 entity와 dto의 일관성을 위해 분리했습니다.