Browse Source

should not make reservation when passenger birthdate is null

feature-pr-PersonAndItinerary
Sona Markosyan 3 years ago
parent
commit
89a20474f5
  1. 1
      src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java
  2. 6
      src/main/java/hs/fulda/de/ci/exam/project/Passenger.java
  3. 8
      src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java

1
src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java

@ -91,6 +91,7 @@ public class Itinerary {
public void validatePassengerDetails(Passenger passenger){ public void validatePassengerDetails(Passenger passenger){
passenger.validateName(); passenger.validateName();
passenger.validatePassportNumber(); passenger.validatePassportNumber();
passenger.validateDate();
} }

6
src/main/java/hs/fulda/de/ci/exam/project/Passenger.java

@ -32,5 +32,9 @@ public class Passenger {
} }
} }
public void validateDate() {
if(dateOfBirth.equals(null)) {
throw new RuntimeException("Birthdate cannot be null");
}
}
} }

8
src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java

@ -85,4 +85,12 @@ public class ItineraryTest {
private static List<String> passportNumberList() { private static List<String> passportNumberList() {
return Arrays.asList("A2", "000000", "AB231837%8"); return Arrays.asList("A2", "000000", "AB231837%8");
} }
@Test
@DisplayName("Should Not Make Reservation when Passenger Birthdate is null")
public void shouldThrowRuntimeExceptionWhenDateIsNull() {
assertThrows(RuntimeException.class, () -> {
item1.makeReservation(new Passenger("John", "AB127389", null));
});
}
} }
Loading…
Cancel
Save