diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Flight.java b/src/main/java/hs/fulda/de/ci/exam/project/Flight.java index 0af18a1..2859020 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/Flight.java +++ b/src/main/java/hs/fulda/de/ci/exam/project/Flight.java @@ -1,5 +1,6 @@ package hs.fulda.de.ci.exam.project; +import java.util.HashSet; import java.util.LinkedList; public class Flight { @@ -7,7 +8,7 @@ public class Flight { Airport departure; Airport arrival; int durationInMinutes; - LinkedList flightInstances; + HashSet flightInstances = new HashSet<>(); public Flight(String flightNumber, Airport departure, Airport arrival, int durationInMinutes) { this.flightNumber = flightNumber; @@ -16,7 +17,7 @@ public class Flight { this.durationInMinutes = durationInMinutes; } - public LinkedList getInstances() { + public HashSet getInstances() { return this.flightInstances; } diff --git a/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java b/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java index b402045..cb4488e 100644 --- a/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java +++ b/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java @@ -2,12 +2,29 @@ package hs.fulda.de.ci.exam.project; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.*; class FlightTest { + + Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany"); + Airport airport_fr = new Airport("Fraport", address_fr, "1234"); + + + Address address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey"); + Airport airport1_ist = new Airport("Istanbul", address1_ist, "5678"); + + Flight flight1 = new Flight("1", airport_fr, airport1_ist, 140); + Flight flight2 = new Flight("2", airport1_ist, airport_fr, 120); + + FlightInstance fInstance1 = new FlightInstance(); + @Test - void getInstances() { + void getInstances_no_instance_should_be_equal() { + HashSet empty_list = new HashSet<>(); + assertThat(flight1.getInstances()).describedAs("get flight instances of the flight ").isEqualTo(empty_list); } @Test