Skip to content
Snippets Groups Projects
Commit fcc12099 authored by Diana Gulčíková's avatar Diana Gulčíková
Browse files

checkstyle fixes

parent 563fcc64
No related branches found
No related tags found
2 merge requests!60Docker,!38Client to call endpoints
Pipeline #
......@@ -23,7 +23,6 @@ class DriverControllerItTest {
@Test
public void testSave() {
// Create a new instance of MyEntity
Driver driver = Driver.builder()
.name("name")
.surname("surname")
......@@ -31,7 +30,7 @@ class DriverControllerItTest {
.characteristics(Map.of()).build();
Driver savedDriver = driverRepository.save(driver);
Assertions.assertEquals(savedDriver, driver);
Assertions.assertEquals(entityManager.find(Driver.class, 1L).getId(), 1);
}
......
......@@ -20,7 +20,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableJpaRepositories(basePackages = "cz.muni.pa165.race.data.repository")
@EnableTransactionManagement
@EntityScan(basePackageClasses = {Race.class, Season.class, Car.class, Driver.class, CarComponent.class})
@EntityScan(basePackageClasses = {Race.class, Season.class, Car.class, Driver.class,
CarComponent.class})
@Import({RestExceptionHandler.class, ClientConfig.class})
public class App {
......
......@@ -62,15 +62,15 @@ public class RaceService {
* Assigns driver one.
*/
public RaceDto assignDriverOne(Long driverId, Long raceId, Long carId) {
var driver = getDriver(driverId);
var car = getCar(carId);
var race = raceRepository.findById(raceId)
.orElseThrow(() -> new DatabaseException("Race not found"));
var driver = getDriver(driverId);
if (race.getDriver2() != null && Objects.equals(race.getDriver2().getDriverId(), driverId)) {
throw new BadRequestException("Driver already assigned to the race as driver two");
}
var car = getCar(carId);
if (race.getDriver2() != null && Objects.equals(race.getDriver2().getCarId(), carId)) {
throw new BadRequestException("Car is already assigned to the race for driver two");
}
......@@ -83,14 +83,14 @@ public class RaceService {
* Assigns driver two.
*/
public RaceDto assignDriverTwo(Long driverId, Long raceId, Long carId) {
var driver = getDriver(driverId);
var car = getCar(carId);
var race = raceRepository.findById(raceId)
.orElseThrow(() -> new DatabaseException("Race not found"));
var driver = getDriver(driverId);
if (race.getDriver1() != null && Objects.equals(race.getDriver1().getDriverId(), driverId)) {
throw new BadRequestException("Driver already assigned to the race as driver one");
}
var car = getCar(carId);
if (race.getDriver1() != null && Objects.equals(race.getDriver1().getCarId(), carId)) {
throw new BadRequestException("Car is already assigned to the race for driver two");
}
......
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