Skip to content
Snippets Groups Projects
Commit 85bc05fd authored by Oto Stanko's avatar Oto Stanko
Browse files

Checkstyle = reality check

parent edd0ebaf
No related branches found
No related tags found
2 merge requests!79Final solution of milestone 3,!6223 persisting data
Pipeline #
......@@ -6,7 +6,6 @@ import cz.muni.pa165.car.restemplate.DbGetter;
import cz.muni.pa165.common_library.dtos.CarComponentResponseDto;
import cz.muni.pa165.common_library.dtos.DriverInsightDto;
import jakarta.annotation.PostConstruct;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
......@@ -46,9 +45,8 @@ public class PersistingCars {
firstCarDrivers,
null);
Optional<Long> componentId = getRandomComponentId();
Optional<Long> driverId = getRandomDriverId();
componentId.ifPresent(id -> firstCar.setComponents(
new HashSet<>(Collections.singleton(id))));
new HashSet<>(Collections.singleton(id))));
carRepository.save(firstCar);
Set<Long> secondCarComponents = new HashSet();
......@@ -60,7 +58,7 @@ public class PersistingCars {
componentId = getRandomComponentId();
componentId.ifPresent(id -> secondCar.setComponents(
new HashSet<>(Collections.singleton(id))));
driverId = getRandomDriverId();
Optional<Long> driverId = getRandomDriverId();
driverId.ifPresent(id -> secondCar.setDrivers(
new HashSet<>(Collections.singleton(id))));
carRepository.save(secondCar);
......@@ -82,7 +80,7 @@ public class PersistingCars {
}
private Optional<Long> getRandomDriverId() {
var response = dbGetter.getAllDriversFromDB();
var response = dbGetter.getAllDriversFromDb();
if (response.isEmpty()) {
return Optional.empty();
}
......
......@@ -35,7 +35,12 @@ public class DbGetter {
return response.getBody();
}
public Optional<List<DriverInsightDto>> getAllDriversFromDB() {
/**
* Calls endpoint of the Driver module and retrieves all the drivers in db.
*
* @return List of all drivers in database.
*/
public Optional<List<DriverInsightDto>> getAllDriversFromDb() {
String url = GET_ALL_DRIVERS_URL;
DriverInsightDto[] drivers;
try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment