Добавил API счетов с ответами 201, 404 и 400 и тестами контроллера

This commit is contained in:
Kashey committed 2026-10-21 23:00:28 +03:00
1 parent cd404fae0b
commit 6dec1fe840
13 files changed
+196 -6

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ public class Account {
public void setName(String name) {
if (name == null || name.isBlank()) {
throw new IllegalArgumentException("Не указано имя счёта");
throw new InvalidAccountNameException("Не указано имя счёта");
}
this.name = name;
}
+22
View File
@@ -0,0 +1,22 @@
package model;
import java.util.HashMap;
import java.util.Map;
public class AccountJournal {
private final Map<Long, Account> accounts = new HashMap<>();
public void saveAccount(Account account) {
if (account == null) {
throw new IllegalArgumentException("Не указан счёт для сохранения в журнал");
}
accounts.put(account.getId(), account);
}
public Account getAccountById(Long id) {
if (id == null) {
throw new IllegalArgumentException("Не указан ID счёта");
}
return accounts.get(id);
}
}
@@ -0,0 +1,8 @@
package model;
public class InvalidAccountNameException extends RuntimeException {
public InvalidAccountNameException(String message)
{
super(message);
}
}
@@ -16,6 +16,9 @@ public class OperationJournal {
}
public Operation getOperationById(Long id) {
if (id == null) {
throw new IllegalArgumentException("Не указан ID операции");
}
return operations.get(id);
}