File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
lesson_15/tdd/tdd_app/src
main/java/com/codedifferently/lesson15
test/java/com/codedifferently/lesson15 Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -45,4 +45,9 @@ public double getSalary() {
4545 public void setSalary (double salary ) {
4646 this .salary = salary ;
4747 }
48+
49+ public boolean containsKey (Object id2 ) {
50+ // TODO Auto-generated method stub
51+ throw new UnsupportedOperationException ("Unimplemented method 'containsKey'" );
52+ }
4853}
Original file line number Diff line number Diff line change 11package com .codedifferently .lesson15 ;
22
3+ import static org .assertj .core .api .Assertions .*;
34import static org .junit .jupiter .api .Assertions .*;
45
56import org .junit .jupiter .api .BeforeEach ;
67import org .junit .jupiter .api .Test ;
78
8- class Lesson15Test {
9+ class EmployeeManagerTest {
910
1011 private EmployeeManager manager ;
1112 private Employee emp ;
@@ -49,4 +50,24 @@ public void testUpdateEmployee() {
4950 manager .getEmployee (1 ),
5051 "Updated employee details should match the new information." );
5152 }
53+
54+ @ Test
55+ public void testRemoveEmployee () {
56+ // Arrange
57+ manager .addEmployee (emp );
58+ // Act
59+ manager .removeEmployee (1 );
60+ Employee removedEmployee = manager .getEmployee (1 );
61+ // Assert
62+ assertEquals (0 , manager .getEmployeeCount (), "Employee count should be 0." );
63+ assertNull (removedEmployee , "Employee should be removed from system." );
64+ }
65+
66+ @ Test
67+ public void testAssertEmployeeInCollection () throws Exception {
68+ // Act
69+ assertThatThrownBy (() -> manager .getEmployee (1 ))
70+ .isInstanceOf (IllegalArgumentException .class )
71+ .hasMessage ("Employee does not in collection with id 1" );
72+ }
5273}
You can’t perform that action at this time.
0 commit comments