.iterator().next();
rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000));
assertEquals(destination, rm.getDestinationToParcel(v1));
assertEquals(ParcelState.AVAILABLE, pm.getParcelState(p1));
final SimulationConverter handle = Solvers.converterBuilder().with(mp)
.with(simAPI).build();
final StateContext sc = handle.convert(SolveArgs.create()
.useParcels(ImmutableSet.<DefaultParcel> of())
.noCurrentRoutes());
assertEquals(1, sc.state.availableParcels.size());
assertEquals(0, sc.state.vehicles.get(0).contents.size());
final Solver solver = SolverValidator.wrap(new MultiVehicleSolverAdapter(
new RandomMVArraysSolver(new MersenneTwister(123)), NonSI.MINUTE));
Solvers.solverBuilder(solver).with(mp).with(simAPI).build().solve(sc);
// give enough time to reach destination
rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000000000));
assertEquals(rm.getPosition(destination), rm.getPosition(v1));
pm.pickup(v1, destination, TimeLapseFactory.create(0, 1));
assertEquals(VehicleState.PICKING_UP, pm.getVehicleState(v1));
final StateContext sc2 = handle.convert(SolveArgs.create()
.useParcels(ImmutableSet.<DefaultParcel> of())
.noCurrentRoutes());
assertEquals(1, sc2.state.availableParcels.size());
assertEquals(0, sc2.state.vehicles.get(0).contents.size());
// finish pickup operation
v1.tick(TimeLapseFactory.create(0, 1000000000));
assertEquals(VehicleState.IDLE, pm.getVehicleState(v1));
final StateContext sc3 = handle.convert(SolveArgs.create()
.useParcels(ImmutableSet.<DefaultParcel> of())
.noCurrentRoutes());
assertTrue(sc3.state.availableParcels.isEmpty());
assertEquals(1, sc3.state.vehicles.get(0).contents.size());
// move to delivery location
rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000));
assertEquals(destination, rm.getDestinationToParcel(v1));
assertEquals(ParcelState.IN_CARGO, pm.getParcelState(p1));
final StateContext sc4 = handle.convert(SolveArgs.create()
.useParcels(ImmutableSet.<DefaultParcel> of())
.noCurrentRoutes());
assertEquals(1, sc4.state.vehicles.get(0).contents.size());
assertTrue(sc4.state.availableParcels.isEmpty());
// service delivery
rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000000000));
assertEquals(destination.dto.destinationLocation, rm.getPosition(v1));
pm.deliver(v1, p1, TimeLapseFactory.create(0, 1));
assertNull(rm.getDestinationToParcel(v1));
assertEquals(VehicleState.DELIVERING, pm.getVehicleState(v1));
final StateContext sc5 = handle.convert(SolveArgs.create()
.useParcels(ImmutableSet.<DefaultParcel> of())
.noCurrentRoutes());
assertEquals(1, sc5.state.vehicles.get(0).contents.size());
assertTrue(sc5.state.availableParcels.isEmpty());
// finish delivery operation
v1.tick(TimeLapseFactory.create(0, 1000000000));
assertEquals(VehicleState.IDLE, pm.getVehicleState(v1));
final StateContext sc6 = handle.convert(SolveArgs.create()
.useParcels(ImmutableSet.<DefaultParcel> of())
.noCurrentRoutes());
assertTrue(sc6.state.vehicles.get(0).contents.isEmpty());
assertTrue(sc6.state.availableParcels.isEmpty());
}