diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java index 53c6aa2d5ae..5a44c12c118 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java @@ -20,14 +20,9 @@ package org.matsim.contrib.drt.optimizer.insertion; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.Sets; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -37,6 +32,7 @@ import org.matsim.contrib.drt.optimizer.insertion.InsertionDetourTimeCalculator.DropoffDetourInfo; import org.matsim.contrib.drt.optimizer.insertion.InsertionDetourTimeCalculator.PickupDetourInfo; import org.matsim.contrib.drt.optimizer.insertion.InsertionGenerator.Insertion; +import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.schedule.DefaultDrtStopTask; import org.matsim.contrib.drt.stops.DefaultStopTimeCalculator; @@ -46,8 +42,12 @@ import org.matsim.contrib.dvrp.fleet.ImmutableDvrpVehicleSpecification; import org.matsim.testcases.fakes.FakeLink; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; /** * @author Michal Maciejewski (michalm) @@ -444,6 +444,32 @@ void startEmpty_twoStops_groupExceedsCapacityAtFirstStop() { ); } + @Test + void testWaypointOccupancyChange() { + int occupancy = 0; + AcceptedDrtRequest acceptedReq5Pax = AcceptedDrtRequest.createFromOriginalRequest(drtRequest5Pax); + AcceptedDrtRequest acceptedReq2Pax = AcceptedDrtRequest.createFromOriginalRequest(drtRequest2Pax); + + Waypoint.Stop stop2 = stop(0, link("stop2"), occupancy); + //dropoff 5 pax + stop2.task.addDropoffRequest(acceptedReq5Pax); + occupancy -= stop2.getOccupancyChange(); + Assertions.assertEquals(5, occupancy); + + Waypoint.Stop stop1 = stop(0, link("stop1"), occupancy); + //dropoff 2 pax, pickup 5 + stop1.task.addDropoffRequest(acceptedReq2Pax); + stop1.task.addPickupRequest(acceptedReq5Pax); + occupancy -= stop1.getOccupancyChange(); + Assertions.assertEquals(2, occupancy); + + + Waypoint.Stop stop0 = stop(0, link("stop0"), occupancy); + stop0.task.addPickupRequest(acceptedReq2Pax); + occupancy -= stop0.getOccupancyChange(); + Assertions.assertEquals(0, occupancy); + } + private Link link(String id) { return new FakeLink(Id.createLinkId(id)); }