diff --git a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/endpoint/HorseEndpoint.java b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/endpoint/HorseEndpoint.java index 3b44980..ad6beed 100644 --- a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/endpoint/HorseEndpoint.java +++ b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/endpoint/HorseEndpoint.java @@ -103,6 +103,10 @@ public class HorseEndpoint { LOGGER.error(e.getMessage()); throw new ResponseStatusException(HttpStatus.PARTIAL_CONTENT, "Operation completed with errors: image could not be saved"); + } catch (NotFoundException e) { + LOGGER.error(e.getMessage()); + throw new ResponseStatusException(HttpStatus.NOT_FOUND, + "The horse requested could not be found"); } } diff --git a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/HorseJdbcDao.java b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/HorseJdbcDao.java index a692716..a321702 100644 --- a/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/HorseJdbcDao.java +++ b/backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/HorseJdbcDao.java @@ -197,7 +197,7 @@ public class HorseJdbcDao implements HorseDao { if (changes == 0) throw new DataAccessException("Updating horse failed, no rows affected") {}; - horse.setUpdatedAt(oldHorse.getUpdatedAt()); + horse.setCreatedAt(oldHorse.getCreatedAt()); fileDao.delete(oldHorse.getImagePath()); diff --git a/backend/src/test/java/at/ac/tuwien/sepm/assignment/individual/unit/persistence/HorseDaoTestBase.java b/backend/src/test/java/at/ac/tuwien/sepm/assignment/individual/unit/persistence/HorseDaoTestBase.java index bea4c53..40089a0 100644 --- a/backend/src/test/java/at/ac/tuwien/sepm/assignment/individual/unit/persistence/HorseDaoTestBase.java +++ b/backend/src/test/java/at/ac/tuwien/sepm/assignment/individual/unit/persistence/HorseDaoTestBase.java @@ -132,7 +132,7 @@ public abstract class HorseDaoTestBase { newHorse.setRace(null); newHorse.setImagePath(null); newHorse.setOwner(null); - assertThrows(DataAccessException.class, () -> horseDao.addHorse(newHorse)); + assertThrows(DataAccessException.class, () -> horseDao.updateHorse(newHorse)); } @Test