Skip to content

Commit dd68734

Browse files
feat: refactor
1 parent c650712 commit dd68734

File tree

1 file changed

+28
-36
lines changed
  • lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/xaviercruz

1 file changed

+28
-36
lines changed
Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,74 @@
11
package com.codedifferently.lesson16.xaviercruz;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertThrows;
5-
63
import java.util.ArrayList;
74
import java.util.Arrays;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertThrows;
88
import org.junit.jupiter.api.Test;
99

1010
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);
1812

1913
@Test
20-
public void testGetName() {
14+
public void testGetName(){
2115
assertEquals("That one guy right there", person.getName());
2216
}
2317

2418
@Test
25-
public void testChangeName() {
19+
public void testChangeName(){
2620
person.changeName("new name right here bruh");
2721
assertEquals("new name right here bruh", person.getName());
2822
}
2923

3024
@Test
31-
public void testGetAge() {
25+
public void testGetAge(){
3226
assertEquals(25, person.getAge());
3327
}
3428

3529
@Test
36-
public void testGetPosition() {
30+
public void testGetPosition(){
3731
assertEquals(Position.ARSONIST, person.getPosition());
3832
}
3933

4034
@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());
4537
}
4638

4739
@Test
48-
public void testGetEyeColor() {
40+
public void testGetEyeColor(){
4941
assertEquals(Color.RED, person.getEyeColor());
5042
}
5143

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+
5254
@Test
53-
public void testIncreaseAge() {
55+
public void testIncreaseAge(){
5456
person.increaseAge();
5557
assertEquals(26, person.getAge());
5658
}
5759

5860
@Test
59-
public void testUpdateAge() {
61+
public void testUpdateAge(){
6062
person.updateAge(99);
6163
assertEquals(99, person.getAge());
6264
}
6365

6466
@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+
});
7272
}
7373

74-
@Test
75-
public void testSetEyeColor() {
76-
Color color = Color.GREEN;
77-
78-
person.setEyeColor(color);
79-
80-
assertEquals(Color.GREEN, person.getEyeColor());
81-
}
8274
}

0 commit comments

Comments
 (0)