From 3b1430d10f87c254824262b8fb5e42a222dd1ca8 Mon Sep 17 00:00:00 2001 From: Sona Markosyan Date: Tue, 8 Feb 2022 18:44:12 +0100 Subject: [PATCH] validate creation date --- .../java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java | 1 + src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java | 4 ++++ .../hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java b/src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java index df0bd9a..941be16 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java +++ b/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(); } } diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java b/src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java index 7663290..00f9b5a 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java +++ b/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")); + } } diff --git a/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java b/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java index e4e48f4..4488bd3 100644 --- a/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java +++ b/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); }); } }