Skip to content

Commit

Permalink
Add boardCost tests for cars.
Browse files Browse the repository at this point in the history
  • Loading branch information
VillePihlava committed Jan 30, 2025
1 parent 8074f17 commit 9a9892c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,26 @@ class RouteRequestMapperCarTest {
void testBasicCarPreferences() {
var carArgs = createArgsCopy(RouteRequestMapperTest.ARGS);
var reluctance = 7.5;
var boardCost = Cost.costOfSeconds(500);
carArgs.put(
"preferences",
Map.ofEntries(entry("street", Map.ofEntries(entry("car", Map.of("reluctance", reluctance)))))
Map.ofEntries(
entry(
"street",
Map.ofEntries(
entry(
"car",
Map.ofEntries(entry("reluctance", reluctance), entry("boardCost", boardCost))
)
)
)
)
);
var env = executionContext(carArgs, Locale.ENGLISH, RouteRequestMapperTest.CONTEXT);
var routeRequest = RouteRequestMapper.toRouteRequest(env, RouteRequestMapperTest.CONTEXT);
var carPreferences = routeRequest.preferences().car();
assertEquals(reluctance, carPreferences.reluctance());
assertEquals(boardCost.toSeconds(), carPreferences.boardCost());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class CarPreferencesTest {

private static final double RELUCTANCE = 5.111;
public static final int BOARD_COST = 550;
private static final double EXPECTED_RELUCTANCE = 5.1;
private static final int PICKUP_TIME = 600;
private static final int PICKUP_COST = 500;
Expand All @@ -22,6 +23,7 @@ class CarPreferencesTest {
private final CarPreferences subject = CarPreferences
.of()
.withReluctance(RELUCTANCE)
.withBoardCost(BOARD_COST)
.withPickupTime(Duration.ofSeconds(PICKUP_TIME))
.withPickupCost(PICKUP_COST)
.withAccelerationSpeed(ACCELERATION_SPEED)
Expand All @@ -35,6 +37,11 @@ void reluctance() {
assertEquals(EXPECTED_RELUCTANCE, subject.reluctance());
}

@Test
void boardCost() {
assertEquals(BOARD_COST, subject.boardCost());
}

@Test
void pickupTime() {
assertEquals(Duration.ofSeconds(PICKUP_TIME), subject.pickupTime());
Expand Down Expand Up @@ -85,6 +92,7 @@ void testToString() {
assertEquals(
"CarPreferences{" +
"reluctance: 5.1, " +
"boardCost: $550, " +
"parking: VehicleParkingPreferences{cost: $30}, " +
"rental: VehicleRentalPreferences{pickupTime: 30s}, " +
"pickupTime: PT10M, " +
Expand Down

0 comments on commit 9a9892c

Please sign in to comment.