Skip to content

Commit 77cd1bf

Browse files
committed
feat: runs gradle checks for added files
1 parent e6b496d commit 77cd1bf

File tree

5 files changed

+48
-51
lines changed

5 files changed

+48
-51
lines changed

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BusinessCheckingAccount.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public class BusinessCheckingAccount extends CheckingAccount {
1313
* @param initialBalance The initial balance of the account.
1414
* @throws IllegalArgumentException if no business owners are provided.
1515
*/
16-
public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, double initialBalance) {
16+
public BusinessCheckingAccount(
17+
String accountNumber, Set<Customer> owners, double initialBalance) {
1718
super(accountNumber, owners, initialBalance);
1819
validateBusinessOwnership(owners);
1920
}
@@ -25,11 +26,11 @@ public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, doubl
2526
* @throws IllegalArgumentException if no business owners are found.
2627
*/
2728
private void validateBusinessOwnership(Set<Customer> owners) {
28-
boolean hasBusinessOwner = owners.stream()
29-
.anyMatch(Customer::isBusiness);
30-
29+
boolean hasBusinessOwner = owners.stream().anyMatch(Customer::isBusiness);
30+
3131
if (!hasBusinessOwner) {
32-
throw new IllegalArgumentException("Business checking account requires at least one business owner");
32+
throw new IllegalArgumentException(
33+
"Business checking account requires at least one business owner");
3334
}
3435
}
3536

@@ -45,4 +46,4 @@ public String toString() {
4546
+ isActive
4647
+ '}';
4748
}
48-
}
49+
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/Customer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Customer {
1212
private final boolean isBusiness;
1313
private final Set<CheckingAccount> accounts = new HashSet<>();
1414

15-
/**
15+
/**
1616
* Creates a new individual customer.
1717
*
1818
* @param id The ID of the customer.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.codedifferently.lesson17.bank;
22

33
public class SavingsAccount extends CheckingAccount {
4-
public SavingsAccount(String accountNumber, double initialBalance) {
5-
super(accountNumber, java.util.Collections.emptySet(), initialBalance);
6-
}
4+
public SavingsAccount(String accountNumber, double initialBalance) {
5+
super(accountNumber, java.util.Collections.emptySet(), initialBalance);
6+
}
77

8-
public void writeCheck(double amount) throws UnsupportedOperationException {
9-
throw new UnsupportedOperationException("Cannot write checks from a savings account");
10-
}
8+
public void writeCheck(double amount) throws UnsupportedOperationException {
9+
throw new UnsupportedOperationException("Cannot write checks from a savings account");
1110
}
11+
}

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class BusinessCheckingAccountTest {
2424
void setUp() {
2525
businessCustomer = new Customer(UUID.randomUUID(), "ABC Corp", true);
2626
individualCustomer = new Customer(UUID.randomUUID(), "John Doe", false);
27-
27+
2828
businessOwners = new HashSet<>();
2929
businessOwners.add(businessCustomer);
3030
businessOwners.add(individualCustomer);
31-
31+
3232
individualOwners = new HashSet<>();
3333
individualOwners.add(individualCustomer);
34-
34+
3535
classUnderTest = new BusinessCheckingAccount("BIZ123456", businessOwners, 1000.0);
3636
}
3737

@@ -54,9 +54,9 @@ void testBusinessCheckingAccountRequiresBusinessOwner() {
5454
void testBusinessCheckingAccountWithOnlyBusinessOwner() {
5555
Set<Customer> onlyBusiness = new HashSet<>();
5656
onlyBusiness.add(businessCustomer);
57-
57+
5858
BusinessCheckingAccount account = new BusinessCheckingAccount("BIZ789", onlyBusiness, 2000.0);
59-
59+
6060
assertEquals("BIZ789", account.getAccountNumber());
6161
assertEquals(2000.0, account.getBalance());
6262
assertEquals(onlyBusiness, account.getOwners());
@@ -68,19 +68,19 @@ void testDepositToBusinessAccount() {
6868
assertEquals(1500.0, classUnderTest.getBalance());
6969
}
7070

71-
@Test
71+
@Test
7272
void testWithdrawFromBusinessAccount() {
7373
classUnderTest.withdraw(300.0);
7474
assertEquals(700.0, classUnderTest.getBalance());
7575
}
7676

77-
@Test
77+
@Test
7878
void testWithdrawMoreThanBalance() {
7979
assertThatExceptionOfType(InsufficientFundsException.class)
8080
.isThrownBy(() -> classUnderTest.withdraw(1500.0));
8181
}
8282

83-
@Test
83+
@Test
8484
void testCloseBusinessAccount() {
8585
classUnderTest.withdraw(1000.0);
8686
classUnderTest.closeAccount();
@@ -89,19 +89,21 @@ void testCloseBusinessAccount() {
8989

9090
@Test
9191
void testBusinessCheckingAccountToString() {
92-
String expected = "BusinessCheckingAccount{accountNumber='BIZ123456', balance=1000.0, isActive=true}";
92+
String expected =
93+
"BusinessCheckingAccount{accountNumber='BIZ123456', balance=1000.0, isActive=true}";
9394
assertEquals(expected, classUnderTest.toString());
9495
}
95-
96-
@Test
96+
97+
@Test
9798
void testBusinessCheckingAccountEquals() {
98-
BusinessCheckingAccount otherAccount = new BusinessCheckingAccount("BIZ123456", businessOwners, 2000.0);
99+
BusinessCheckingAccount otherAccount =
100+
new BusinessCheckingAccount("BIZ123456", businessOwners, 2000.0);
99101
assertEquals(classUnderTest, otherAccount);
100102
}
101103

102-
@Test
104+
@Test
103105
void testBusinessCheckingAccountInheritance() {
104106
// Verify it inherits all CheckingAccount functionality
105107
assertTrue(classUnderTest instanceof CheckingAccount);
106108
}
107-
}
109+
}

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

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,29 @@
22

33
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
44
import static org.junit.jupiter.api.Assertions.assertEquals;
5-
import static org.junit.jupiter.api.Assertions.assertFalse;
6-
import static org.junit.jupiter.api.Assertions.assertTrue;
75

8-
import com.codedifferently.lesson17.bank.exceptions.InsufficientFundsException;
9-
import java.util.HashSet;
10-
import java.util.Set;
11-
import java.util.UUID;
126
import org.junit.jupiter.api.BeforeEach;
137
import org.junit.jupiter.api.Test;
148

159
class SavingsAccountTest {
16-
17-
private SavingsAccount classUnderTest;
1810

19-
@BeforeEach
20-
void setUp() {
21-
classUnderTest = new SavingsAccount("987654321", 200.0);
22-
}
11+
private SavingsAccount classUnderTest;
2312

24-
@Test
25-
void writeCheckThrowsException() {
26-
assertThatExceptionOfType(UnsupportedOperationException.class)
27-
.isThrownBy(() -> classUnderTest.writeCheck(50.0))
28-
.withMessage("Cannot write checks from a savings account");
29-
}
13+
@BeforeEach
14+
void setUp() {
15+
classUnderTest = new SavingsAccount("987654321", 200.0);
16+
}
3017

31-
@Test
32-
void testSavingsAccountCreation() {
33-
assertEquals("987654321", classUnderTest.getAccountNumber());
34-
assertEquals(200.0, classUnderTest.getBalance());
35-
}
36-
}
18+
@Test
19+
void writeCheckThrowsException() {
20+
assertThatExceptionOfType(UnsupportedOperationException.class)
21+
.isThrownBy(() -> classUnderTest.writeCheck(50.0))
22+
.withMessage("Cannot write checks from a savings account");
23+
}
24+
25+
@Test
26+
void testSavingsAccountCreation() {
27+
assertEquals("987654321", classUnderTest.getAccountNumber());
28+
assertEquals(200.0, classUnderTest.getBalance());
29+
}
30+
}

0 commit comments

Comments
 (0)