1+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
12import static org .junit .jupiter .api .Assertions .assertEquals ;
2- import static org .junit .jupiter .api .Assertions .assertNull ;
33
44import com .codedifferently .lesson15 .Employee ;
55import com .codedifferently .lesson15 .EmployeeManager ;
@@ -30,40 +30,44 @@ public void testAddEmployee() {
3030 }
3131
3232 @ Test
33- public void testgetEmployee () {
33+ public void testUpdateEmployee () {
3434 // Arrange
35- Employee employee = new Employee (2 , "Washington" , "Finance" , 29.23 );
35+ Employee employee = new Employee (5 , "John" , "Safety" , 50 );
36+ cut .addEmployee (employee );
3637
3738 // Act
38- Employee returnedEmployee = cut .getEmployee (employee . getId () );
39+ cut .updateEmployee (employee );
3940
4041 // Assert
41- assertNull (returnedEmployee );
42+ int expectedId = 5 ;
43+ assertEquals (expectedId , employee .getId ());
4244 }
4345
4446 @ Test
4547 public void testRemoveEmployee () {
4648 // Arrange
47- Employee employee = new Employee (3 , "Belvedere" , "Finance" , 100.1 );
48-
49+ Employee employee = new Employee (2 , "Belvedere" , "Finance" , 100.1 );
50+ cut . addEmployee ( employee );
4951 // Act
5052 cut .removeEmployee (employee .getId ());
5153
5254 // Assert
53- int removedId = 3 ;
54- assertNull (cut .getEmployee (removedId ));
55+ int removedId = 2 ;
56+ assertThatThrownBy (() -> cut .removeEmployee (removedId ))
57+ .isInstanceOf (IllegalArgumentException .class )
58+ .hasMessage ("Employee does not in collection with id " + removedId );
5559 }
5660
5761 @ Test
58- public void testUpdateEmployee () {
62+ public void testGetEmployee () {
5963 // Arrange
60- Employee employee = new Employee (5 , "John" , "Safety" , 50 );
61-
64+ Employee employee = new Employee (2 , "Washington" , "Finance" , 29.23 );
6265 // Act
63- cut .updateEmployee (employee );
66+ cut .addEmployee (employee );
6467
68+ int employeeId = employee .getId ();
69+ Employee returnedEmployee = cut .getEmployee (employeeId );
6570 // Assert
66- int expectedId = 5 ;
67- assertEquals (expectedId , employee .getId ());
71+ assertEquals (employee , returnedEmployee );
6872 }
69- }
73+ }
0 commit comments