forked from ironhack-labs/lab-java-exceptions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonsListTest.java
More file actions
31 lines (26 loc) · 1 KB
/
PersonsListTest.java
File metadata and controls
31 lines (26 loc) · 1 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
28
29
30
31
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class PersonsListTest {
@Test
public void testFindByName() {
PersonsList list = new PersonsList();
Person person = new Person(1, "John Doe", 25, "Engineer");
list.addPerson(person);
assertEquals(person, list.findByName("John Doe"));
}
@Test
public void testFindByNameInvalidFormat() {
PersonsList list = new PersonsList();
assertThrows(IllegalArgumentException.class, () -> list.findByName("JohnDoe"));
}
@Test
public void testClone() {
PersonsList list = new PersonsList();
Person original = new Person(1, "John Doe", 25, "Engineer");
Person clone = list.clone(original);
assertNotEquals(original.getId(), clone.getId());
assertEquals(original.getName(), clone.getName());
assertEquals(original.getAge(), clone.getAge());
assertEquals(original.getOccupation(), clone.getOccupation());
}
}