|
|
@ -4,19 +4,50 @@ import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.mockito.junit.MockitoJUnitRunner; |
|
|
|
|
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.junit.jupiter.api.Assertions.fail; |
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
|
|
|
@RunWith(MockitoJUnitRunner.class) |
|
|
|
public class AirlineTest { |
|
|
|
@Test |
|
|
|
void testConstructorSetsNameParameterCorrectly() { |
|
|
|
Airline airline = new Airline("Pegasus", "1234"); |
|
|
|
assertThat(airline.getName()).describedAs("name of airline").isEqualTo("Pegasus"); |
|
|
|
assertThat(airline.getName()) |
|
|
|
.describedAs("name of airline") |
|
|
|
.isEqualTo("Pegasus"); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testConstructorSetsCodeParameterCorrectly() { |
|
|
|
Airline airline = new Airline("Pegasus", "1234"); |
|
|
|
assertThat(airline.getCode()).describedAs("code of airline").isEqualTo("1234"); |
|
|
|
assertThat(airline.getCode()) |
|
|
|
.describedAs("code of airline") |
|
|
|
.isEqualTo("1234"); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void getFlightsReturnsEmptyListOfFlights() { |
|
|
|
Airline airline = new Airline("Pegasus", "1234"); |
|
|
|
HashSet<Flight> flights = new HashSet<>(); |
|
|
|
assertThat(airline.getFlights()) |
|
|
|
.describedAs("flights of airline") |
|
|
|
.isEqualTo(flights); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void addFlightAddsFlightToListOfFlights() { |
|
|
|
Airline airline = new Airline("Pegasus", "1234"); |
|
|
|
Flight flight1 = mock(Flight.class); |
|
|
|
HashSet<Flight> flights = new HashSet<>(); |
|
|
|
flights.add(flight1); |
|
|
|
|
|
|
|
airline.addFlight(flight1); |
|
|
|
|
|
|
|
assertThat(airline.getFlights()) |
|
|
|
.describedAs("flights of airline") |
|
|
|
.isEqualTo(flights); |
|
|
|
} |
|
|
|
|
|
|
|
} |