Skip to content

Commit 661de15

Browse files
committed
fix(test): adds spotlessApply to Bank Tests
1 parent af05354 commit 661de15

File tree

2 files changed

+49
-34
lines changed

2 files changed

+49
-34
lines changed

lesson_17/bank/bank_app/src/test/java/com/codedifferently/lesson17/bank/BankAtmIntegrationTest.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
import java.util.Set;
66
import java.util.UUID;
7-
87
import org.junit.jupiter.api.BeforeEach;
98
import org.junit.jupiter.api.Test;
109

1110
/**
12-
* Integration tests for BankAtm to verify support for different account types.
13-
* These tests focus on validating that SavingsAccount and BusinessCheckingAccount
14-
* are properly integrated with the BankAtm system.
11+
* Integration tests for BankAtm to verify support for different account types. These tests focus on
12+
* validating that SavingsAccount and BusinessCheckingAccount are properly integrated with the
13+
* BankAtm system.
1514
*/
1615
class BankAtmIntegrationTest {
1716

@@ -28,9 +27,11 @@ void testBankAtmSupportsAllAccountTypes() {
2827
Customer regularCustomer = new Customer(UUID.randomUUID(), "John Doe");
2928
BusinessCustomer businessCustomer = new BusinessCustomer(UUID.randomUUID(), "ABC Corp");
3029

31-
CheckingAccount checkingAccount = new CheckingAccount("CHK-001", Set.of(regularCustomer), 1000.0);
30+
CheckingAccount checkingAccount =
31+
new CheckingAccount("CHK-001", Set.of(regularCustomer), 1000.0);
3232
SavingsAccount savingsAccount = new SavingsAccount("SAV-001", Set.of(regularCustomer), 5000.0);
33-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-001", "ABC Corp", businessCustomer);
33+
BusinessCheckingAccount businessAccount =
34+
new BusinessCheckingAccount("BIZ-001", "ABC Corp", businessCustomer);
3435
businessAccount.deposit(10000.0);
3536

3637
// Link accounts to customers
@@ -44,8 +45,10 @@ void testBankAtmSupportsAllAccountTypes() {
4445
bankAtm.addAccount(businessAccount);
4546

4647
// Assert - Verify all accounts are accessible
47-
Set<Account> regularCustomerAccounts = bankAtm.findAccountsByCustomerId(regularCustomer.getId());
48-
Set<Account> businessCustomerAccounts = bankAtm.findAccountsByCustomerId(businessCustomer.getId());
48+
Set<Account> regularCustomerAccounts =
49+
bankAtm.findAccountsByCustomerId(regularCustomer.getId());
50+
Set<Account> businessCustomerAccounts =
51+
bankAtm.findAccountsByCustomerId(businessCustomer.getId());
4952

5053
assertThat(regularCustomerAccounts).containsExactlyInAnyOrder(checkingAccount, savingsAccount);
5154
assertThat(businessCustomerAccounts).containsOnly(businessAccount);
@@ -59,7 +62,8 @@ void testCashOperationsWorkWithAllAccountTypes() {
5962

6063
CheckingAccount checkingAccount = new CheckingAccount("CHK-CASH", Set.of(customer), 1000.0);
6164
SavingsAccount savingsAccount = new SavingsAccount("SAV-CASH", Set.of(customer), 2000.0);
62-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-CASH", "Test Business", businessCustomer);
65+
BusinessCheckingAccount businessAccount =
66+
new BusinessCheckingAccount("BIZ-CASH", "Test Business", businessCustomer);
6367
businessAccount.deposit(5000.0);
6468

6569
customer.addAccount(checkingAccount);
@@ -97,7 +101,8 @@ void testCheckOperationsWorkWithAllAccountTypes() {
97101

98102
CheckingAccount sourceChecking = new CheckingAccount("CHK-SOURCE", Set.of(individual), 3000.0);
99103
SavingsAccount targetSavings = new SavingsAccount("SAV-TARGET", Set.of(individual), 1000.0);
100-
BusinessCheckingAccount targetBusiness = new BusinessCheckingAccount("BIZ-TARGET", "Target Business", business);
104+
BusinessCheckingAccount targetBusiness =
105+
new BusinessCheckingAccount("BIZ-TARGET", "Target Business", business);
101106
targetBusiness.deposit(5000.0);
102107

103108
individual.addAccount(sourceChecking);
@@ -127,12 +132,14 @@ void testCheckOperationsWorkWithAllAccountTypes() {
127132
void testBusinessAccountSpecificFeatures() {
128133
// Arrange - Business account with business customer
129134
BusinessCustomer businessOwner = new BusinessCustomer(UUID.randomUUID(), "Tech Startup LLC");
130-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-STARTUP", "Tech Startup LLC", businessOwner);
135+
BusinessCheckingAccount businessAccount =
136+
new BusinessCheckingAccount("BIZ-STARTUP", "Tech Startup LLC", businessOwner);
131137
businessAccount.deposit(50000.0);
132138
businessOwner.addAccount(businessAccount);
133139

134140
Customer regularCustomer = new Customer(UUID.randomUUID(), "Regular Customer");
135-
CheckingAccount regularAccount = new CheckingAccount("CHK-REGULAR", Set.of(regularCustomer), 2000.0);
141+
CheckingAccount regularAccount =
142+
new CheckingAccount("CHK-REGULAR", Set.of(regularCustomer), 2000.0);
136143
regularCustomer.addAccount(regularAccount);
137144

138145
bankAtm.addAccount(businessAccount);
@@ -193,7 +200,8 @@ void testComplexScenarioWithAllAccountTypes() {
193200
SavingsAccount aliceSavings = new SavingsAccount("SAV-ALICE", Set.of(alice), 15000.0);
194201

195202
// Company has business account
196-
BusinessCheckingAccount companyAccount = new BusinessCheckingAccount("BIZ-XYZ", "Company XYZ", companyXYZ);
203+
BusinessCheckingAccount companyAccount =
204+
new BusinessCheckingAccount("BIZ-XYZ", "Company XYZ", companyXYZ);
197205
companyAccount.deposit(100000.0);
198206

199207
// Bob has checking

lesson_17/bank/bank_app/src/test/java/com/codedifferently/lesson17/bank/BankAtmTest.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import static org.assertj.core.api.Assertions.assertThat;
44
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
55

6+
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
7+
import com.codedifferently.lesson17.bank.exceptions.CheckVoidedException;
68
import java.util.Set;
79
import java.util.UUID;
8-
910
import org.junit.jupiter.api.BeforeEach;
1011
import org.junit.jupiter.api.Test;
1112

12-
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
13-
import com.codedifferently.lesson17.bank.exceptions.CheckVoidedException;
14-
1513
class BankAtmTest {
1614

1715
private BankAtm classUnderTest;
@@ -192,11 +190,13 @@ void testWithdrawFunds_SavingsAccount() {
192190
void testDepositFunds_CheckToSavingsAccount() {
193191
// Arrange - Create source checking account and target savings account
194192
Customer sourceCustomer = new Customer(UUID.randomUUID(), "Source Customer");
195-
CheckingAccount sourceAccount = new CheckingAccount("CHK-SOURCE", Set.of(sourceCustomer), 500.0);
196-
193+
CheckingAccount sourceAccount =
194+
new CheckingAccount("CHK-SOURCE", Set.of(sourceCustomer), 500.0);
195+
197196
Customer targetCustomer = new Customer(UUID.randomUUID(), "Target Customer");
198-
SavingsAccount targetSavingsAccount = new SavingsAccount("SAV-TARGET", Set.of(targetCustomer), 1000.0);
199-
197+
SavingsAccount targetSavingsAccount =
198+
new SavingsAccount("SAV-TARGET", Set.of(targetCustomer), 1000.0);
199+
200200
sourceCustomer.addAccount(sourceAccount);
201201
targetCustomer.addAccount(targetSavingsAccount);
202202
classUnderTest.addAccount(sourceAccount);
@@ -218,7 +218,8 @@ void testDepositFunds_CheckToSavingsAccount() {
218218
void testAddBusinessCheckingAccount() {
219219
// Arrange
220220
BusinessCustomer businessCustomer = new BusinessCustomer(UUID.randomUUID(), "ABC Corp");
221-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-123456", "ABC Corp", businessCustomer);
221+
BusinessCheckingAccount businessAccount =
222+
new BusinessCheckingAccount("BIZ-123456", "ABC Corp", businessCustomer);
222223
businessCustomer.addAccount(businessAccount);
223224

224225
// Act
@@ -233,7 +234,8 @@ void testAddBusinessCheckingAccount() {
233234
void testDepositFunds_BusinessCheckingAccount() {
234235
// Arrange
235236
BusinessCustomer businessCustomer = new BusinessCustomer(UUID.randomUUID(), "ABC Corp");
236-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-123456", "ABC Corp", businessCustomer);
237+
BusinessCheckingAccount businessAccount =
238+
new BusinessCheckingAccount("BIZ-123456", "ABC Corp", businessCustomer);
237239
businessCustomer.addAccount(businessAccount);
238240
classUnderTest.addAccount(businessAccount);
239241

@@ -248,7 +250,8 @@ void testDepositFunds_BusinessCheckingAccount() {
248250
void testWithdrawFunds_BusinessCheckingAccount() {
249251
// Arrange
250252
BusinessCustomer businessCustomer = new BusinessCustomer(UUID.randomUUID(), "ABC Corp");
251-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-123456", "ABC Corp", businessCustomer);
253+
BusinessCheckingAccount businessAccount =
254+
new BusinessCheckingAccount("BIZ-123456", "ABC Corp", businessCustomer);
252255
businessAccount.deposit(10000.0); // Add initial funds
253256
businessCustomer.addAccount(businessAccount);
254257
classUnderTest.addAccount(businessAccount);
@@ -264,12 +267,14 @@ void testWithdrawFunds_BusinessCheckingAccount() {
264267
void testDepositFunds_CheckToBusinessCheckingAccount() {
265268
// Arrange - Create source checking account and target business account
266269
Customer sourceCustomer = new Customer(UUID.randomUUID(), "Individual Customer");
267-
CheckingAccount sourceAccount = new CheckingAccount("CHK-INDIVIDUAL", Set.of(sourceCustomer), 3000.0);
268-
270+
CheckingAccount sourceAccount =
271+
new CheckingAccount("CHK-INDIVIDUAL", Set.of(sourceCustomer), 3000.0);
272+
269273
BusinessCustomer businessCustomer = new BusinessCustomer(UUID.randomUUID(), "XYZ Corp");
270-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-XYZ", "XYZ Corp", businessCustomer);
274+
BusinessCheckingAccount businessAccount =
275+
new BusinessCheckingAccount("BIZ-XYZ", "XYZ Corp", businessCustomer);
271276
businessAccount.deposit(5000.0); // Initial business account balance
272-
277+
273278
sourceCustomer.addAccount(sourceAccount);
274279
businessCustomer.addAccount(businessAccount);
275280
classUnderTest.addAccount(sourceAccount);
@@ -289,12 +294,14 @@ void testDepositFunds_CheckToBusinessCheckingAccount() {
289294
void testDepositFunds_CheckFromBusinessAccount() {
290295
// Arrange - Business account writing check to individual account
291296
BusinessCustomer businessCustomer = new BusinessCustomer(UUID.randomUUID(), "Business Corp");
292-
BusinessCheckingAccount businessAccount = new BusinessCheckingAccount("BIZ-CORP", "Business Corp", businessCustomer);
297+
BusinessCheckingAccount businessAccount =
298+
new BusinessCheckingAccount("BIZ-CORP", "Business Corp", businessCustomer);
293299
businessAccount.deposit(10000.0); // Initial business account balance
294-
300+
295301
Customer individualCustomer = new Customer(UUID.randomUUID(), "John Individual");
296-
CheckingAccount individualAccount = new CheckingAccount("CHK-INDIVIDUAL", Set.of(individualCustomer), 500.0);
297-
302+
CheckingAccount individualAccount =
303+
new CheckingAccount("CHK-INDIVIDUAL", Set.of(individualCustomer), 500.0);
304+
298305
businessCustomer.addAccount(businessAccount);
299306
individualCustomer.addAccount(individualAccount);
300307
classUnderTest.addAccount(businessAccount);
@@ -318,7 +325,7 @@ void testFindAccountsByCustomerId_WithMultipleAccountTypes() {
318325
Customer customer = new Customer(UUID.randomUUID(), "Multi Account Customer");
319326
CheckingAccount checkingAccount = new CheckingAccount("CHK-MULTI", Set.of(customer), 1000.0);
320327
SavingsAccount savingsAccount = new SavingsAccount("SAV-MULTI", Set.of(customer), 5000.0);
321-
328+
322329
customer.addAccount(checkingAccount);
323330
customer.addAccount(savingsAccount);
324331
classUnderTest.addAccount(checkingAccount);
@@ -338,7 +345,7 @@ void testTransferBetweenDifferentAccountTypes() {
338345
Customer customer = new Customer(UUID.randomUUID(), "Transfer Customer");
339346
CheckingAccount checkingAccount = new CheckingAccount("CHK-TRANSFER", Set.of(customer), 2000.0);
340347
SavingsAccount savingsAccount = new SavingsAccount("SAV-TRANSFER", Set.of(customer), 3000.0);
341-
348+
342349
customer.addAccount(checkingAccount);
343350
customer.addAccount(savingsAccount);
344351
classUnderTest.addAccount(checkingAccount);

0 commit comments

Comments
 (0)