@Test void get_all_vehicles() { VehicleEntity vehicleEntity = vehicleEntity(testVehicle); when(crudRepository.findAll()).thenReturn(Collections.singletonList(vehicleEntity)); assertThat(repository.vehicles()).containsExactly(testVehicle); }
@Override public List<Vehicle> vehicles() { return StreamSupport.stream(repository.findAll().spliterator(), false) .map(VehicleRepositoryImpl::toDomain) .collect(toList()); }
VehicleRepositoryImpl implements VehicleRepository { @Override public List<Vehicle> vehicles() { return StreamSupport.stream(repository.findAll().spliterator(), false) .map(VehicleRepositoryImpl::toDomain) .collect(toList()); } }
VehicleRepositoryImpl implements VehicleRepository { @Override public List<Vehicle> vehicles() { return StreamSupport.stream(repository.findAll().spliterator(), false) .map(VehicleRepositoryImpl::toDomain) .collect(toList()); } VehicleRepositoryImpl(VehicleCrudRepository repository); }
VehicleRepositoryImpl implements VehicleRepository { @Override public List<Vehicle> vehicles() { return StreamSupport.stream(repository.findAll().spliterator(), false) .map(VehicleRepositoryImpl::toDomain) .collect(toList()); } VehicleRepositoryImpl(VehicleCrudRepository repository); @Override Vehicle createVehicle(int capacity); @Override Vehicle createVehicle(VehicleData vehicleData); @Override List<Vehicle> vehicles(); @Override Vehicle removeVehicle(long id); @Override void removeAll(); @Override Optional<Vehicle> find(long vehicleId); @Override void update(Vehicle vehicle); }
VehicleRepositoryImpl implements VehicleRepository { @Override public List<Vehicle> vehicles() { return StreamSupport.stream(repository.findAll().spliterator(), false) .map(VehicleRepositoryImpl::toDomain) .collect(toList()); } VehicleRepositoryImpl(VehicleCrudRepository repository); @Override Vehicle createVehicle(int capacity); @Override Vehicle createVehicle(VehicleData vehicleData); @Override List<Vehicle> vehicles(); @Override Vehicle removeVehicle(long id); @Override void removeAll(); @Override Optional<Vehicle> find(long vehicleId); @Override void update(Vehicle vehicle);  }