VehicleService { public void removeVehicle(long vehicleId) { Vehicle vehicle = vehicleRepository.removeVehicle(vehicleId); optimizer.removeVehicle(vehicle); } @Autowired  VehicleService(RouteOptimizer optimizer, VehicleRepository vehicleRepository); void createVehicle(); void createVehicle(VehicleData vehicleData); void addVehicle(Vehicle vehicle); void removeVehicle(long vehicleId); synchronized void removeAnyVehicle(); void removeAll(); void changeCapacity(long vehicleId, int capacity);  }
@Test void removeVehicle() { final long vehicleId = 8; final Vehicle vehicle = VehicleFactory.testVehicle(vehicleId); when(vehicleRepository.removeVehicle(vehicleId)).thenReturn(vehicle); vehicleService.removeVehicle(vehicleId); verify(vehicleRepository).removeVehicle(vehicleId); verify(optimizer).removeVehicle(vehicle); }