-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: 차량 엔티티 테스트 * test: 차량 재고 엔티티 테스트 * test: 차량 예약 엔티티 테스트 * test: 차량 시험 수행 엔티티 테스트 * refactor: 엔티티 팩토리 구현 및 리팩토링 * test: 시험 수행 이력 서비스 단위 테스트 구현 * test: 차량 재고 서비스 단위 테스트 구현 * test: 시험차량 예약 테스트 및 리팩토링 * test: 차량 재고 테스트 수정 * feat: 차량 서비스 단위 테스트 구현
- Loading branch information
Showing
31 changed files
with
1,490 additions
and
25 deletions.
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
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
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
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
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
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
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
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
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
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
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
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
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
68 changes: 68 additions & 0 deletions
68
src/test/java/com/testcar/car/common/CarEntityFactory.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,68 @@ | ||
package com.testcar.car.common; | ||
|
||
import static com.testcar.car.common.Constant.CAR_DISPLACEMENT; | ||
import static com.testcar.car.common.Constant.CAR_NAME; | ||
import static com.testcar.car.common.Constant.CAR_STOCK_NUMBER; | ||
import static com.testcar.car.common.Constant.CAR_TEST_RESULT; | ||
import static com.testcar.car.common.Constant.CAR_TYPE; | ||
import static com.testcar.car.common.Constant.EXPIRED_AT; | ||
import static com.testcar.car.common.Constant.STARTED_AT; | ||
|
||
import com.testcar.car.domains.car.entity.Car; | ||
import com.testcar.car.domains.car.entity.Car.CarBuilder; | ||
import com.testcar.car.domains.carReservation.entity.CarReservation; | ||
import com.testcar.car.domains.carReservation.entity.CarReservation.CarReservationBuilder; | ||
import com.testcar.car.domains.carReservation.entity.ReservationStatus; | ||
import com.testcar.car.domains.carStock.entity.CarStock; | ||
import com.testcar.car.domains.carStock.entity.CarStock.CarStockBuilder; | ||
import com.testcar.car.domains.carStock.entity.StockStatus; | ||
import com.testcar.car.domains.carTest.entity.CarTest; | ||
import com.testcar.car.domains.carTest.entity.CarTest.CarTestBuilder; | ||
|
||
public class CarEntityFactory { | ||
private CarEntityFactory() {} | ||
|
||
public static Car createCar() { | ||
return createCarBuilder().build(); | ||
} | ||
|
||
public static CarBuilder createCarBuilder() { | ||
return Car.builder().name(CAR_NAME).displacement(CAR_DISPLACEMENT).type(CAR_TYPE); | ||
} | ||
|
||
public static CarStock createCarStock() { | ||
return createCarStockBuilder().build(); | ||
} | ||
|
||
public static CarStockBuilder createCarStockBuilder() { | ||
return CarStock.builder() | ||
.car(createCar()) | ||
.stockNumber(CAR_STOCK_NUMBER) | ||
.status(StockStatus.AVAILABLE); | ||
} | ||
|
||
public static CarReservation createCarReservation() { | ||
return createCarReservationBuilder().build(); | ||
} | ||
|
||
public static CarReservationBuilder createCarReservationBuilder() { | ||
return CarReservation.builder() | ||
.member(MemberEntityFactory.createMember()) | ||
.carStock(createCarStock()) | ||
.startedAt(STARTED_AT) | ||
.expiredAt(EXPIRED_AT) | ||
.status(ReservationStatus.RESERVED); | ||
} | ||
|
||
public static CarTest createCarTest() { | ||
return createCarTestBuilder().build(); | ||
} | ||
|
||
public static CarTestBuilder createCarTestBuilder() { | ||
return CarTest.builder() | ||
.member(MemberEntityFactory.createMember()) | ||
.carStock(createCarStock()) | ||
.performedAt(STARTED_AT) | ||
.result(CAR_TEST_RESULT); | ||
} | ||
} |
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,38 @@ | ||
package com.testcar.car.common; | ||
|
||
|
||
import com.testcar.car.domains.car.entity.Type; | ||
import com.testcar.car.domains.member.Role; | ||
import java.time.LocalDateTime; | ||
|
||
public class Constant { | ||
private Constant() {} | ||
|
||
/** Member */ | ||
public static final String MEMBER_EMAIL = "[email protected]"; | ||
|
||
public static final String MEMBER_PASSWORD = "1234abcd@"; | ||
public static final String MEMBER_NAME = "홍길동"; | ||
public static final Role MEMBER_ROLE = Role.ADMIN; | ||
public static final String DEPARTMENT_NAME = "모비스시스템팀"; | ||
|
||
/** Car */ | ||
public static final String CAR_NAME = "아반떼"; | ||
|
||
public static final String ANOTHER_CAR_NAME = "소나타"; | ||
public static final double CAR_DISPLACEMENT = 1.6; | ||
public static final Type CAR_TYPE = Type.SEDAN; | ||
public static final String CAR_STOCK_NUMBER = "123456789012"; | ||
public static final String ANOTHER_CAR_STOCK_NUMBER = "987654321098"; | ||
public static final LocalDateTime STARTED_AT = LocalDateTime.of(2021, 1, 1, 0, 0, 0); | ||
public static final LocalDateTime EXPIRED_AT = LocalDateTime.of(2021, 1, 8, 0, 0, 0); | ||
public static final String CAR_TEST_RESULT = "통과"; | ||
|
||
/** Track */ | ||
public static final String TRACK_NAME = "서산주행시험장"; | ||
|
||
public static final String ANOTHER_TRACK_NAME = "마포주행시험장"; | ||
public static final String TRACK_LOCATION = "충청남도 서산시 부석면"; | ||
public static final String TRACK_DESCRIPTION = "비탈길"; | ||
public static final double TRACK_LENGTH = 12.6; | ||
} |
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,30 @@ | ||
package com.testcar.car.common; | ||
|
||
import static com.testcar.car.common.CarEntityFactory.createCarStock; | ||
import static com.testcar.car.common.CarEntityFactory.createCarTest; | ||
import static com.testcar.car.common.TrackEntityFactory.createTrack; | ||
|
||
import com.testcar.car.domains.car.entity.Car; | ||
import com.testcar.car.domains.carStock.entity.CarStock; | ||
import com.testcar.car.domains.carTest.model.vo.CarTestDto; | ||
import com.testcar.car.domains.department.entity.Department; | ||
import com.testcar.car.domains.member.Member; | ||
|
||
public class DtoFactory { | ||
private DtoFactory() {} | ||
|
||
public static CarTestDto createCarTestDto() { | ||
final Member member = MemberEntityFactory.createMember(); | ||
final Department department = member.getDepartment(); | ||
final CarStock carStock = createCarStock(); | ||
final Car car = carStock.getCar(); | ||
return new CarTestDto( | ||
createCarTest(), | ||
createTrack(), | ||
member.getName(), | ||
member.getName(), | ||
department.getName(), | ||
car.getName(), | ||
carStock.getStockNumber()); | ||
} | ||
} |
Oops, something went wrong.