US03: Fix bug where the horse jdbc dao returned a false updated_at value, add additional exception handling to horse update endpoint
This commit is contained in:
parent
62bbb0644b
commit
6376282cbd
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user