Browse Source

refactor Airport

feature-pr-AirportClass
Imron 3 years ago
parent
commit
544cedf28d
  1. 22
      src/main/java/hs/fulda/de/ci/exam/project/Address.java
  2. 15
      src/main/java/hs/fulda/de/ci/exam/project/Airport.java
  3. 13
      src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java
  4. 43
      src/main/java/hs/fulda/de/ci/exam/project/Flight.java
  5. 4
      src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java
  6. 52
      src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java
  7. 49
      src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java
  8. 11
      src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java
  9. 36
      src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java
  10. BIN
      target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class
  11. BIN
      target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class

22
src/main/java/hs/fulda/de/ci/exam/project/Address.java

@ -1,6 +1,28 @@
package hs.fulda.de.ci.exam.project; package hs.fulda.de.ci.exam.project;
public class Address { public class Address {
String streetAddress;
String city;
String state;
String zipCode;
String country;
public Address(String streetAddress, String city, String state, String zipCode, String country) { public Address(String streetAddress, String city, String state, String zipCode, String country) {
this.streetAddress = streetAddress;
this.city = city;
this.state = state;
this.zipCode = zipCode;
this.country = country;
}
@Override
public String toString() {
return "Address{" +
"streetAddress='" + streetAddress + '\'' +
", city='" + city + '\'' +
", state='" + state + '\'' +
", zipCode='" + zipCode + '\'' +
", country='" + country + '\'' +
'}';
} }
} }

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

@ -4,10 +4,16 @@ import java.util.LinkedList;
public class Airport { public class Airport {
protected String name;
public Address address; public Address address;
public LinkedList<Flight> flights;
protected String code; protected String code;
protected String name;
public LinkedList<Flight> flights = new LinkedList<>();
public Airport(String name, Address address, String code) {
this.name = name;
this.address = address;
this.code = code;
}
public String getName() { public String getName() {
return this.name; return this.name;
@ -24,4 +30,9 @@ public class Airport {
public LinkedList<Flight> getFlights() { public LinkedList<Flight> getFlights() {
return this.flights; return this.flights;
} }
@Override
public String toString() {
return "Airport{" + "name='" + name + '\'' + ", address=" + address + ", code='" + code + '\'' + '}';
}
} }

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

@ -1,13 +0,0 @@
package hs.fulda.de.ci.exam.project;
import java.util.LinkedList;
public class ExampleClass {
public static void main(String[] args) {
LinkedList<String> list = new LinkedList<>();
list.add("heello");
list.add("world");
list.remove("heello");
System.out.println(list);
}
}

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

@ -1,4 +1,47 @@
package hs.fulda.de.ci.exam.project; package hs.fulda.de.ci.exam.project;
import java.util.LinkedList;
public class Flight { public class Flight {
String flightNumber;
Airport departure;
Airport arrival;
int durationInMinutes;
LinkedList<FlightInstance> flightInstances;
public Flight(String flightNumber, Airport departure, Airport arrival, int durationInMinutes) {
this.flightNumber = flightNumber;
this.departure = departure;
this.arrival = arrival;
this.durationInMinutes = durationInMinutes;
}
public LinkedList<FlightInstance> getInstances() {
return this.flightInstances;
}
public boolean cancel() {
return true;
}
public boolean addFlightSchedule() {
return true;
}
public String getFlightNumber() {
return flightNumber;
}
public Airport getDeparture() {
return departure;
}
public Airport getArrival() {
return arrival;
}
public int getDurationInMinutes() {
return durationInMinutes;
}
} }

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

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

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

@ -1,52 +0,0 @@
package hs.fulda.de.ci.exam.project;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.LinkedList;
import static org.assertj.core.api.Assertions.*;
@ExtendWith(MockitoExtension.class)
public class AirportClassTest {
@Test
void test_getName(){
Airport airport = new Airport();
airport.name = "fraport";
assertThat(airport.getName()).describedAs("get airport name").isEqualTo("fraport");
}
@Test
void test_getCode(){
Airport airport = new Airport();
airport.code = "PC994";
assertThat(airport.getCode()).describedAs("get airport code").isEqualTo("PC994");
}
@Test
void test_getAddress(){
Airport airport = new Airport();
Address address = new Address("Mittelstr", "Fulda", "Hessen", "36037", "Germany");
airport.address = 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);
}
}

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

@ -0,0 +1,49 @@
package hs.fulda.de.ci.exam.project;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.LinkedList;
import static org.assertj.core.api.Assertions.*;
@ExtendWith(MockitoExtension.class)
public class AirportTest {
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);
@Test
void test_getName() {
assertThat(airport_fr.getName()).describedAs("get airport name").isEqualTo("Fraport");
}
@Test
void test_getCode() {
assertThat(airport_fr.getCode()).describedAs("get airport code").isEqualTo("1234");
}
@Test
void test_getAddress() {
assertThat(airport_fr.getAddress()).describedAs("get address of airport").isEqualTo(address_fr);
}
@Test
void test_getFlights() {
LinkedList<Flight> flist = new LinkedList<>();
flist.add(flight1);
airport_fr.flights.add(flight1);
assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist);
}
}

11
src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java

@ -1,11 +0,0 @@
package hs.fulda.de.ci.exam.project;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ExampleClassTest {
@Test
void testExampleClass() {
assertTrue(true);
}
}

36
src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java

@ -0,0 +1,36 @@
package hs.fulda.de.ci.exam.project;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class FlightTest {
@Test
void getInstances() {
}
@Test
void cancel() {
}
@Test
void addFlightSchedule() {
}
@Test
void getFlightNumber() {
}
@Test
void getDeparture() {
}
@Test
void getArrival() {
}
@Test
void getDurationInMinutes() {
}
}

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

BIN
target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class

Loading…
Cancel
Save