Skip to content

Commit f6868a2

Browse files
author
AmiyahJo
committed
feat: adds testBusinessCheckingAccount
1 parent 71e7dd2 commit f6868a2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.codedifferently.lesson17.bank;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
import java.util.UUID;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertThrows;
9+
import org.junit.jupiter.api.Test;
10+
11+
class BusinessCheckingAccountTest {
12+
13+
@Test
14+
void testConstructorWithBusinessOwner() {
15+
Set<com.codedifferently.lesson17.bank.Customer> owners = new HashSet<>();
16+
owners.add(new Customer(UUID.randomUUID(), "John Doe", true));
17+
BusinessCheckingAccount account = new BusinessCheckingAccount("12345", owners, "Tech Corp", 1000.0);
18+
assertEquals("Tech Corp", account.getBusinessName());
19+
}
20+
21+
@Test
22+
void testConstructorWithoutBusinessOwner() {
23+
Set<com.codedifferently.lesson17.bank.Customer> owners = new HashSet<>();
24+
owners.add(new Customer(UUID.randomUUID(), "Jane Doe", false));
25+
26+
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
27+
new BusinessCheckingAccount("12345", owners, "Tech Corp", 1000.0);
28+
});
29+
30+
assertEquals("At least one owner must be a business.", exception.getMessage());
31+
}
32+
}

0 commit comments

Comments
 (0)