Browse Source

should not create itinerary when starting airport is null

feature-pr-FrontDeskOfficer
Sona Markosyan 3 years ago
parent
commit
32c81ede92
  1. 20
      src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java

20
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 {
@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");
final FrontDeskOfficer frontDeskOfficer = new FrontDeskOfficer("John", address1, "example@email.com", "0151238967");
@Test
public void shouldCreateItinerary() {
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());
});
}
}
Loading…
Cancel
Save