Browse Source

validate creation date

feature-pr-FrontDeskOfficer
Sona Markosyan 3 years ago
parent
commit
3b1430d10f
  1. 1
      src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java
  2. 4
      src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java
  3. 2
      src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java

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

@ -37,5 +37,6 @@ public class FrontDeskOfficer extends Person{
public void validateItinerary(Itinerary itinerary){ public void validateItinerary(Itinerary itinerary){
itinerary.validateStartAirport(); itinerary.validateStartAirport();
itinerary.validateFinalAirport(); itinerary.validateFinalAirport();
itinerary.validateCreationDate();
} }
} }

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

@ -82,5 +82,9 @@ public class Itinerary {
if(this.final_airport.getName().isBlank()) if(this.final_airport.getName().isBlank())
throw new RuntimeException(("Destination Airport Cannot be null or empty")); throw new RuntimeException(("Destination Airport Cannot be null or empty"));
} }
public void validateCreationDate() {
if(this.creationDate.equals(null))
throw new RuntimeException(("Creation Date should not be null or empty"));
}
} }

2
src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java

@ -36,7 +36,7 @@ public class FrontDeskOfficerTest {
@DisplayName("Should Not Create Itinerary when Destination Airport is null") @DisplayName("Should Not Create Itinerary when Destination Airport is null")
public void shouldThrowRuntimeExceptionWhenFinalAirportIsNull(){ public void shouldThrowRuntimeExceptionWhenFinalAirportIsNull(){
assertThrows(RuntimeException.class, () -> { assertThrows(RuntimeException.class, () -> {
frontDeskOfficer.createItinerary(airport_fr, null, new Date());
frontDeskOfficer.createItinerary(airport_fr, airport_be, null);
}); });
} }
} }
Loading…
Cancel
Save