feat: ExchangeController & tests

This commit is contained in:
Piotr Dec 2024-05-25 00:33:33 +02:00
parent 720937bd6c
commit 95ed5f6ae7
Signed by: stawros
GPG key ID: F89F27AD8F881A91
8 changed files with 85 additions and 21 deletions

View file

@ -2,6 +2,7 @@ package eu.ztsh.wymiana.service;
import eu.ztsh.wymiana.exception.ExchangeFailedException;
import eu.ztsh.wymiana.exception.InsufficientFundsException;
import eu.ztsh.wymiana.exception.UserNotFoundException;
import eu.ztsh.wymiana.model.Currency;
import eu.ztsh.wymiana.model.User;
import eu.ztsh.wymiana.validation.InstanceValidator;
@ -49,7 +50,7 @@ public class CurrencyService {
user.currencies().putAll(exchanged);
return userService.update(user);
})
.orElseThrow(ExchangeFailedException::new);
.orElseThrow(() -> new UserNotFoundException(request));
}
private Currency create(String symbol) {