Browse Source

getFlights with two flights

feature-pr-AirportClass
Imron 3 years ago
parent
commit
3854b84607
  1. 7
      src/main/java/hs/fulda/de/ci/exam/project/Airport.java
  2. 17
      src/test/java/hs/fulda/de/ci/exam/project/AddressTest.java
  3. 20
      src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java

7
src/main/java/hs/fulda/de/ci/exam/project/Airport.java

@ -1,13 +1,14 @@
package hs.fulda.de.ci.exam.project; package hs.fulda.de.ci.exam.project;
import java.util.LinkedList;
import java.util.HashSet;
import java.util.Set;
public class Airport { public class Airport {
protected String name; protected String name;
public Address address; public Address address;
protected String code; protected String code;
public LinkedList<Flight> flights = new LinkedList<>();
public HashSet<Flight> flights = new HashSet<>();
public Airport(String name, Address address, String code) { public Airport(String name, Address address, String code) {
this.name = name; this.name = name;
@ -27,7 +28,7 @@ public class Airport {
return this.address; return this.address;
} }
public LinkedList<Flight> getFlights() {
public HashSet<Flight> getFlights() {
return this.flights; return this.flights;
} }

17
src/test/java/hs/fulda/de/ci/exam/project/AddressTest.java

@ -0,0 +1,17 @@
package hs.fulda.de.ci.exam.project;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class AddressTest {
@BeforeEach
void setUp() {
}
@Test
void testToString() {
}
}

20
src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java

@ -1,9 +1,11 @@
package hs.fulda.de.ci.exam.project; package hs.fulda.de.ci.exam.project;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@ -11,6 +13,7 @@ import static org.assertj.core.api.Assertions.*;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class AirportTest { public class AirportTest {
Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany"); Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany");
Airport airport_fr = new Airport("Fraport", address_fr, "1234"); Airport airport_fr = new Airport("Fraport", address_fr, "1234");
@ -39,11 +42,26 @@ public class AirportTest {
@Test @Test
void test_getFlights() { void test_getFlights() {
LinkedList<Flight> flist = new LinkedList<>();
HashSet<Flight> flist = new HashSet<>();
flist.add(flight1);
airport_fr.flights.add(flight1);
assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist);
}
@Test
void test_getFlights_wiht_2_flights() {
HashSet<Flight> flist = new HashSet<>();
flist.add(flight1); flist.add(flight1);
flist.add(flight2);
airport_fr.flights.add(flight1); airport_fr.flights.add(flight1);
airport_fr.flights.add(flight1);
airport_fr.flights.add(flight2);
assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist); assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist);
} }
} }
Loading…
Cancel
Save