From 32c81ede92b0b1cedde845cb34d56f876f398e9c Mon Sep 17 00:00:00 2001 From: Sona Markosyan Date: Tue, 8 Feb 2022 18:38:02 +0100 Subject: [PATCH] should not create itinerary when starting airport is null --- .../ci/exam/project/FrontDeskOfficerTest.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) 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()); + }); + } }