Payment creation with validation and response

* Move mapping inside service
 * Extract validation to utility class
 * Add test for validation
This commit is contained in:
2023-05-12 11:42:21 +02:00
parent 2f8bf45383
commit 1757546f29
18 changed files with 615 additions and 61 deletions

View File

@@ -1,3 +1,4 @@
-- Users
INSERT INTO BANKING_USER (ID, USERNAME, PASSWORD)
VALUES (1, 'user1', '{bcrypt}$2a$10$4dPs2u01F/UBJtQyKRCRLevJACUkDzSdD.4EFKkf0T0qllqtkxw5e');
INSERT INTO BANKING_USER (ID, USERNAME, PASSWORD)
@@ -15,6 +16,7 @@ VALUES (7, 'user7', '{bcrypt}$2a$10$w/CSC.FmoFEbGBJ5lPF3oe0gbZmo3n1wOQK9W50DbDHs
INSERT INTO BANKING_USER (ID, USERNAME, PASSWORD)
VALUES (8, 'user8', '{bcrypt}$2a$10$L1RWBgjH0L.YJG/uyMhviubSxz8C.PnZJlviF6K/iueeDrWO.FSOy');
-- Bank accounts
INSERT INTO BANK_ACCOUNT (ID, ACCOUNT_NAME, ACCOUNT_NUMBER, STATUS)
VALUES (1, 'Personal', 'LU584022594948990503', 'ENABLED');
INSERT INTO BANK_ACCOUNT (ID, ACCOUNT_NAME, ACCOUNT_NUMBER, STATUS)
@@ -56,6 +58,89 @@ VALUES (19, 'Savings', 'LU130189044953642517', 'ENABLED');
INSERT INTO BANK_ACCOUNT (ID, ACCOUNT_NAME, ACCOUNT_NUMBER, STATUS)
VALUES (20, 'Trading', 'LU081651725326393823', 'ENABLED');
-- Balances
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 1, 578.98, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 2, 578.98, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 3, 4135.14, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 4, 4135.14, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 5, 21545.32, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 6, 21545.32, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 7, 201.00, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 8, 201.00, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 9, 984512.23, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 10, 984512.23, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 11, 382690.16, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 12, 382690.16, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 13, 232663.94, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 14, 232663.94, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 15, 421234.41, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 16, 421234.41, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 17, 158052.05, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 18, 158052.05, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 19, 292888.94, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 20, 292888.94, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 21, 168211.44, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 22, 168211.44, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 23, 223757.44, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 24, 223757.44, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 25, 207268.46, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 26, 207268.46, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 27, 326704.48, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 28, 326704.48, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 29, 98377.59, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 30, 98377.59, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 31, 23818.53, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 32, 23818.53, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 33, 252442.60, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 34, 252442.60, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 35, 412747.20, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 36, 412747.20, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 37, 359691.69, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 38, 359691.69, 'EUR', 'END_OF_DAY' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 39, 278739.76, 'EUR', 'AVAILABLE' );
INSERT INTO BALANCE (ID, AMOUNT, CURRENCY, TYPE)
VALUES ( 40, 278739.76, 'EUR', 'END_OF_DAY' );
-- User/Bank account association
INSERT INTO BANK_ACCOUNT_USERS (BANK_ACCOUNT_ID, USER_ID)
VALUES (1, 1);
INSERT INTO BANK_ACCOUNT_USERS (BANK_ACCOUNT_ID, USER_ID)
@@ -110,3 +195,86 @@ INSERT INTO BANK_ACCOUNT_USERS (BANK_ACCOUNT_ID, USER_ID)
VALUES (19, 2);
INSERT INTO BANK_ACCOUNT_USERS (BANK_ACCOUNT_ID, USER_ID)
VALUES (20, 8);
-- Balance / Bank account association
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (1, 1);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (1, 2);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (2, 3);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (2, 4);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (3, 5);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (3, 6);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (4, 7);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (4, 8);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (5, 9);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (5, 10);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (6, 11);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (6, 12);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (7, 13);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (7, 14);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (8, 15);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (8, 16);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (9, 17);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (9, 18);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (10, 19);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (10, 20);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (11, 21);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (11, 22);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (12, 23);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (12, 24);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (13, 25);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (13, 26);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (14, 27);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (14, 28);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (15, 29);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (15, 30);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (16, 31);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (16, 32);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (17, 33);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (17, 34);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (18, 35);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (18, 36);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (19, 37);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (19, 38);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (20, 39);
INSERT INTO BANK_ACCOUNT_BALANCES (BANK_ACCOUNT_ID, BALANCE_ID)
VALUES (20, 40);