-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContactTest.java
More file actions
27 lines (24 loc) · 1.05 KB
/
ContactTest.java
File metadata and controls
27 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ContactTest {
@Test
public void testContactCreation() {
Contact contact = new Contact("12345", "John", "Doe", "1234567890", "123 Elm St");
assertEquals("12345", contact.getContactId());
assertEquals("John", contact.getFirstName());
assertEquals("Doe", contact.getLastName());
assertEquals("1234567890", contact.getPhone());
assertEquals("123 Elm St", contact.getAddress());
}
@Test
public void testInvalidContactId() {
assertThrows(IllegalArgumentException.class, () -> new Contact(null, "John", "Doe", "1234567890", "123 Elm St"));
assertThrows(IllegalArgumentException.class, () -> new Contact("12345678901", "John", "Doe", "1234567890", "123 Elm St"));
}
@Test
public void testSetters() {
Contact contact = new Contact("12345", "John", "Doe", "1234567890", "123 Elm St");
contact.setFirstName("Jane");
assertEquals("Jane", contact.getFirstName());
}
}