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){
itinerary.validateStartAirport();
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())
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")
public void shouldThrowRuntimeExceptionWhenFinalAirportIsNull(){
assertThrows(RuntimeException.class, () -> {
frontDeskOfficer.createItinerary(airport_fr, null, new Date());
frontDeskOfficer.createItinerary(airport_fr, airport_be, null);
});
}
}
Loading…
Cancel
Save