Browse Source

get instance empty list

feature-pr-PersonClass
Imron 3 years ago
parent
commit
281a0b27ac
  1. 5
      src/main/java/hs/fulda/de/ci/exam/project/Flight.java
  2. 21
      src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java

5
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<FlightInstance> flightInstances;
HashSet<FlightInstance> 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<FlightInstance> getInstances() {
public HashSet<FlightInstance> getInstances() {
return this.flightInstances;
}

21
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<FlightInstance> empty_list = new HashSet<>();
assertThat(flight1.getInstances()).describedAs("get flight instances of the flight ").isEqualTo(empty_list);
}
@Test

Loading…
Cancel
Save