From 85bc05fdd2b8b188553b549b9230f90de72cd2f9 Mon Sep 17 00:00:00 2001 From: Oto Stanko <493068@fi.muni.cz> Date: Mon, 1 May 2023 16:35:36 +0200 Subject: [PATCH] Checkstyle = reality check --- .../java/cz/muni/pa165/car/config/PersistingCars.java | 8 +++----- .../main/java/cz/muni/pa165/car/restemplate/DbGetter.java | 7 ++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/car/src/main/java/cz/muni/pa165/car/config/PersistingCars.java b/car/src/main/java/cz/muni/pa165/car/config/PersistingCars.java index 4a414ef7..766d7765 100644 --- a/car/src/main/java/cz/muni/pa165/car/config/PersistingCars.java +++ b/car/src/main/java/cz/muni/pa165/car/config/PersistingCars.java @@ -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(); } diff --git a/car/src/main/java/cz/muni/pa165/car/restemplate/DbGetter.java b/car/src/main/java/cz/muni/pa165/car/restemplate/DbGetter.java index faee0a62..7364a762 100644 --- a/car/src/main/java/cz/muni/pa165/car/restemplate/DbGetter.java +++ b/car/src/main/java/cz/muni/pa165/car/restemplate/DbGetter.java @@ -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 { -- GitLab