Browse Source

refactor airlinetest

feature-pr-AirlineClass
Imron 3 years ago
parent
commit
9da2331c58
  1. 12
      src/test/java/hs/fulda/de/ci/exam/project/AirlineTest.java

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

@ -11,9 +11,13 @@ import static org.mockito.Mockito.mock;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class AirlineTest { public class AirlineTest {
Airline airline = new Airline("Pegasus", "1234");
Flight flight1 = mock(Flight.class);
HashSet<Flight> flights = new HashSet<>();
@Test @Test
void testConstructorSetsNameParameterCorrectly() { void testConstructorSetsNameParameterCorrectly() {
Airline airline = new Airline("Pegasus", "1234");
assertThat(airline.getName()) assertThat(airline.getName())
.describedAs("name of airline") .describedAs("name of airline")
.isEqualTo("Pegasus"); .isEqualTo("Pegasus");
@ -21,7 +25,6 @@ public class AirlineTest {
@Test @Test
void testConstructorSetsCodeParameterCorrectly() { void testConstructorSetsCodeParameterCorrectly() {
Airline airline = new Airline("Pegasus", "1234");
assertThat(airline.getCode()) assertThat(airline.getCode())
.describedAs("code of airline") .describedAs("code of airline")
.isEqualTo("1234"); .isEqualTo("1234");
@ -29,8 +32,6 @@ public class AirlineTest {
@Test @Test
void getFlightsReturnsEmptyListOfFlights() { void getFlightsReturnsEmptyListOfFlights() {
Airline airline = new Airline("Pegasus", "1234");
HashSet<Flight> flights = new HashSet<>();
assertThat(airline.getFlights()) assertThat(airline.getFlights())
.describedAs("flights of airline") .describedAs("flights of airline")
.isEqualTo(flights); .isEqualTo(flights);
@ -38,9 +39,6 @@ public class AirlineTest {
@Test @Test
void addFlightAddsFlightToListOfFlights() { void addFlightAddsFlightToListOfFlights() {
Airline airline = new Airline("Pegasus", "1234");
Flight flight1 = mock(Flight.class);
HashSet<Flight> flights = new HashSet<>();
flights.add(flight1); flights.add(flight1);
airline.addFlight(flight1); airline.addFlight(flight1);

Loading…
Cancel
Save