diff --git a/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java b/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java index 2293945..12cd3b4 100644 --- a/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java +++ b/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java @@ -1,26 +1,34 @@ package hs.fulda.de.ci.exam.project; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import java.util.Date; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class FrontDeskOfficerTest { + + final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany"); + final Airport airport_fr = new Airport("Fraport", address1, "1234"); + final Airport airport_be = new Airport("Berlin", address1, "5678"); + final FrontDeskOfficer frontDeskOfficer = new FrontDeskOfficer("John", address1, "example@email.com", "0151238967"); + @Test public void shouldCreateItinerary() { - final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany"); - final Airport airport_fr = new Airport("Fraport", address1, "1234"); - final Airport airport_be = new Airport("Berlin", address1, "5678"); - FrontDeskOfficer frontDeskOfficer = new FrontDeskOfficer("John", address1, "example@email.com", "0151238967"); - frontDeskOfficer.createItinerary(airport_fr, airport_be, new Date()); assertFalse(frontDeskOfficer.getAllItineraries().isEmpty()); assertEquals(1, frontDeskOfficer.getAllItineraries().size()); assertTrue(frontDeskOfficer.getAllItineraries().stream().filter(itinerary -> itinerary.getStart_airport().equals(airport_fr) && itinerary.getFinal_airport().equals(airport_be)).findAny().isPresent()); } + @Test + @DisplayName("Should Not Create Itinerary when Starting Airport is null") + public void shouldThrowRuntimeExceptionWhenStartAirportIsNull(){ + assertThrows(RuntimeException.class, () -> { + frontDeskOfficer.createItinerary(null, airport_be, new Date()); + }); + } }