Browse Source

add aircraft throws exception mockito test

feature-pr-Admin
Sona Markosyan 3 years ago
parent
commit
7e364c71b9
  1. 9
      src/test/java/hs/fulda/de/ci/exam/project/AdminTest.java

9
src/test/java/hs/fulda/de/ci/exam/project/AdminTest.java

@ -126,4 +126,13 @@ public class AdminTest {
} }
assertNotNull(admin.addAircraft("Boeing", "787", 2003)); assertNotNull(admin.addAircraft("Boeing", "787", 2003));
} }
@Test
public void testAddAircraft_throwsException() throws IOException {
when(aircraftRepository.save(any(Aircraft.class))).thenThrow(IOException.class);
assertThrows(IOException.class, () -> {
admin.addAircraft("Boeing", "787", 2003);
});
}
} }
Loading…
Cancel
Save