|
@ -1,26 +1,34 @@ |
|
|
package hs.fulda.de.ci.exam.project; |
|
|
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.junit.jupiter.api.Test; |
|
|
import org.mockito.InjectMocks; |
|
|
import org.mockito.InjectMocks; |
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
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 { |
|
|
public class FrontDeskOfficerTest { |
|
|
@Test |
|
|
|
|
|
public void shouldCreateItinerary() { |
|
|
|
|
|
|
|
|
|
|
|
final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany"); |
|
|
final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany"); |
|
|
final Airport airport_fr = new Airport("Fraport", address1, "1234"); |
|
|
final Airport airport_fr = new Airport("Fraport", address1, "1234"); |
|
|
final Airport airport_be = new Airport("Berlin", address1, "5678"); |
|
|
final Airport airport_be = new Airport("Berlin", address1, "5678"); |
|
|
FrontDeskOfficer frontDeskOfficer = new FrontDeskOfficer("John", address1, "example@email.com", "0151238967"); |
|
|
|
|
|
|
|
|
final FrontDeskOfficer frontDeskOfficer = new FrontDeskOfficer("John", address1, "example@email.com", "0151238967"); |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void shouldCreateItinerary() { |
|
|
frontDeskOfficer.createItinerary(airport_fr, airport_be, new Date()); |
|
|
frontDeskOfficer.createItinerary(airport_fr, airport_be, new Date()); |
|
|
assertFalse(frontDeskOfficer.getAllItineraries().isEmpty()); |
|
|
assertFalse(frontDeskOfficer.getAllItineraries().isEmpty()); |
|
|
assertEquals(1, frontDeskOfficer.getAllItineraries().size()); |
|
|
assertEquals(1, frontDeskOfficer.getAllItineraries().size()); |
|
|
assertTrue(frontDeskOfficer.getAllItineraries().stream().filter(itinerary -> itinerary.getStart_airport().equals(airport_fr) && |
|
|
assertTrue(frontDeskOfficer.getAllItineraries().stream().filter(itinerary -> itinerary.getStart_airport().equals(airport_fr) && |
|
|
itinerary.getFinal_airport().equals(airport_be)).findAny().isPresent()); |
|
|
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()); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |