|
1 | 1 | package com.codedifferently.lesson16.xaviercruz; |
2 | 2 |
|
3 | | -import static org.junit.jupiter.api.Assertions.assertEquals; |
4 | | -import static org.junit.jupiter.api.Assertions.assertThrows; |
5 | | - |
6 | 3 | import java.util.ArrayList; |
7 | 4 | import java.util.Arrays; |
| 5 | + |
| 6 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 7 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
8 | 8 | import org.junit.jupiter.api.Test; |
9 | 9 |
|
10 | 10 | public class PersonTest { |
11 | | - Person person = |
12 | | - new Person( |
13 | | - "That one guy right there", |
14 | | - 25, |
15 | | - Position.ARSONIST, |
16 | | - new ArrayList<>(Arrays.asList("Tall", "Insane", "Funny", "something else here idk")), |
17 | | - Color.RED); |
| 11 | + Person person = new Person("That one guy right there", 25, Position.ARSONIST, new ArrayList<>(Arrays.asList("Tall", "Insane", "Funny", "something else here idk")), Color.RED); |
18 | 12 |
|
19 | 13 | @Test |
20 | | - public void testGetName() { |
| 14 | + public void testGetName(){ |
21 | 15 | assertEquals("That one guy right there", person.getName()); |
22 | 16 | } |
23 | 17 |
|
24 | 18 | @Test |
25 | | - public void testChangeName() { |
| 19 | + public void testChangeName(){ |
26 | 20 | person.changeName("new name right here bruh"); |
27 | 21 | assertEquals("new name right here bruh", person.getName()); |
28 | 22 | } |
29 | 23 |
|
30 | 24 | @Test |
31 | | - public void testGetAge() { |
| 25 | + public void testGetAge(){ |
32 | 26 | assertEquals(25, person.getAge()); |
33 | 27 | } |
34 | 28 |
|
35 | 29 | @Test |
36 | | - public void testGetPosition() { |
| 30 | + public void testGetPosition(){ |
37 | 31 | assertEquals(Position.ARSONIST, person.getPosition()); |
38 | 32 | } |
39 | 33 |
|
40 | 34 | @Test |
41 | | - public void testGetTraits() { |
42 | | - assertEquals( |
43 | | - new ArrayList<>(Arrays.asList("Tall", "Insane", "Funny", "something else here idk")), |
44 | | - person.getTraits()); |
| 35 | + public void testGetTraits(){ |
| 36 | + assertEquals(new ArrayList<>(Arrays.asList("Tall", "Insane", "Funny", "something else here idk")), person.getTraits()); |
45 | 37 | } |
46 | 38 |
|
47 | 39 | @Test |
48 | | - public void testGetEyeColor() { |
| 40 | + public void testGetEyeColor(){ |
49 | 41 | assertEquals(Color.RED, person.getEyeColor()); |
50 | 42 | } |
51 | 43 |
|
| 44 | + @Test |
| 45 | + public void testSetEyeColor() { |
| 46 | + Color color = Color.GREEN; |
| 47 | + |
| 48 | + person.setEyeColor(color); |
| 49 | + |
| 50 | + assertEquals(Color.GREEN, person.getEyeColor()); |
| 51 | + } |
| 52 | + |
| 53 | + |
52 | 54 | @Test |
53 | | - public void testIncreaseAge() { |
| 55 | + public void testIncreaseAge(){ |
54 | 56 | person.increaseAge(); |
55 | 57 | assertEquals(26, person.getAge()); |
56 | 58 | } |
57 | 59 |
|
58 | 60 | @Test |
59 | | - public void testUpdateAge() { |
| 61 | + public void testUpdateAge(){ |
60 | 62 | person.updateAge(99); |
61 | 63 | assertEquals(99, person.getAge()); |
62 | 64 | } |
63 | 65 |
|
64 | 66 | @Test |
65 | | - public void testAddToTraits_Exception() { |
66 | | - String[] newTraits = new String[] {"test", "test", "test", "test", "test", "test", "test"}; |
67 | | - assertThrows( |
68 | | - TooManyTraitsException.class, |
69 | | - () -> { |
70 | | - person.addToTraits(newTraits); |
71 | | - }); |
| 67 | + public void testAddToTraits_Exception(){ |
| 68 | + String[] newTraits = new String[]{"test", "test", "test", "test", "test", "test", "test"}; |
| 69 | + assertThrows(TooManyTraitsException.class, () -> { |
| 70 | + person.addToTraits(newTraits); |
| 71 | + }); |
72 | 72 | } |
73 | 73 |
|
74 | | - @Test |
75 | | - public void testSetEyeColor() { |
76 | | - Color color = Color.GREEN; |
77 | | - |
78 | | - person.setEyeColor(color); |
79 | | - |
80 | | - assertEquals(Color.GREEN, person.getEyeColor()); |
81 | | - } |
82 | 74 | } |
0 commit comments