Browse Source

getFlights()

feature-pr-AirportClass
Imron 3 years ago
parent
commit
2d25baa99a
  1. 7
      src/main/java/hs/fulda/de/ci/exam/project/Airport.java
  2. 5
      src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java
  3. 4
      src/main/java/hs/fulda/de/ci/exam/project/Flight.java
  4. 12
      src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java
  5. BIN
      target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class

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

@ -1,8 +1,11 @@
package hs.fulda.de.ci.exam.project; package hs.fulda.de.ci.exam.project;
import java.util.LinkedList;
public class Airport { public class Airport {
public Address address; public Address address;
public LinkedList<Flight> flights;
protected String code; protected String code;
protected String name; protected String name;
@ -17,4 +20,8 @@ public class Airport {
public Address getAddress() { public Address getAddress() {
return this.address; return this.address;
} }
public LinkedList<Flight> getFlights() {
return this.flights;
}
} }

5
src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java

@ -4,5 +4,10 @@ import java.util.LinkedList;
public class ExampleClass { public class ExampleClass {
public static void main(String[] args) { public static void main(String[] args) {
LinkedList<String> list = new LinkedList<>();
list.add("heello");
list.add("world");
list.remove("heello");
System.out.println(list);
} }
} }

4
src/main/java/hs/fulda/de/ci/exam/project/Flight.java

@ -0,0 +1,4 @@
package hs.fulda.de.ci.exam.project;
public class Flight {
}

12
src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java

@ -5,6 +5,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import java.util.LinkedList;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@ -33,6 +35,16 @@ public class AirportClassTest {
assertThat(airport.getAddress()).describedAs("get address of airport").isEqualTo(address); assertThat(airport.getAddress()).describedAs("get address of airport").isEqualTo(address);
} }
@Test
void test_getFlights(){
Airport airport = new Airport();
LinkedList<Flight> flights = new LinkedList<>();
Flight flight1 = new Flight();
flights.add(flight1);
airport.flights = flights;
assertThat(airport.getFlights()).describedAs("get all flights of the airport").isEqualTo(flights);
}

BIN
target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class

Loading…
Cancel
Save