You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.8 KiB
84 lines
2.8 KiB
package hs.fulda.de.ci.exam.project;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.sql.Time;
|
|
import java.util.HashSet;
|
|
|
|
import static hs.fulda.de.ci.exam.project.FlightStatus.Active;
|
|
import static hs.fulda.de.ci.exam.project.FlightStatus.Cancelled;
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
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(new Time(12, 45, 00), "4E", Active);
|
|
|
|
@Test
|
|
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
|
|
void getInstances_not_empty_list_should_be_equal() {
|
|
HashSet<FlightInstance> list = new HashSet<>();
|
|
list.add(fInstance1);
|
|
|
|
flight1.flightInstances.add(fInstance1);
|
|
assertThat(flight1.getInstances()).describedAs("get flight instances of the flight ").isEqualTo(list);
|
|
}
|
|
|
|
@Test
|
|
void addFlightScheduleShoudlAddFlightInstanceWithActiveStatus() {
|
|
boolean addInstance = flight1.addFlightSchedule(fInstance1);
|
|
assertTrue(addInstance);
|
|
FlightStatus result = flight1.getFlightInstance(fInstance1).getStatus();
|
|
FlightStatus expected = Active;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
void cancelingFlightShouldChangeActiveToCancelled() {
|
|
boolean addInstance = flight1.addFlightSchedule(fInstance1);
|
|
assertTrue(addInstance);
|
|
flight1.cancel(fInstance1);
|
|
FlightStatus result = flight1.getFlightInstance(fInstance1).getStatus();
|
|
FlightStatus expected = Cancelled;
|
|
assertThat(expected).isEqualTo(result);
|
|
}
|
|
|
|
@Test
|
|
void getFlightNumber() {
|
|
assertThat(flight1.getFlightNumber()).describedAs("get flight number of the flight").isEqualTo("1");
|
|
}
|
|
|
|
@Test
|
|
void getDeparture() {
|
|
assertThat(flight1.getDeparture()).describedAs("get departure of flight").isEqualTo(airport_fr);
|
|
|
|
}
|
|
|
|
@Test
|
|
void getArrival() {
|
|
assertThat(flight1.getArrival()).describedAs("get arrival of flight").isEqualTo(airport1_ist);
|
|
|
|
}
|
|
|
|
@Test
|
|
void getDurationInMinutes() {
|
|
assertThat(flight1.getDurationInMinutes()).describedAs("get duration of flight").isEqualTo(140);
|
|
|
|
}
|
|
}
|