From 5a87ad7caec2618a10ee2e378fa0578c49f36eff Mon Sep 17 00:00:00 2001 From: Imron Date: Mon, 31 Jan 2022 22:03:01 +0100 Subject: [PATCH] aircraft refactor --- .../de/ci/exam/project/AircraftTest.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java index 14468b8..bb126b9 100644 --- a/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java +++ b/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java @@ -8,45 +8,42 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; public class AircraftTest { + + Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990); + HashSet flights = new HashSet<>(); + Flight flight1 = mock(Flight.class); + Flight flight2 = mock(Flight.class); + @Test - public void testClassAircraftConstructorName(){ - Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990); + public void testClassAircraftConstructorName() { assertThat(testAircraft.getName()) .describedAs("get the name of aircraft") .isEqualTo("Airbus"); } @Test - public void testClassAircraftConstructorModel(){ - Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990); + public void testClassAircraftConstructorModel() { assertThat(testAircraft.getModel()) .describedAs("get the model of aircraft") .isEqualTo("Neo"); } + @Test - public void testClassAircraftConstructorManifacturingYear(){ - Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990); + public void testClassAircraftConstructorManifacturingYear() { assertThat(testAircraft.getManYear()) .describedAs("get the manifacturing year of aircraft") .isEqualTo(1990); } @Test - public void test_getFlightsEmptyList(){ - Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990); - HashSet flights = new HashSet<>(); + public void test_getFlightsEmptyList() { assertThat(testAircraft.getFlights()) .describedAs("get the manifacturing year of aircraft") .isEqualTo(flights); } @Test - public void test_getFlights_wiht_2_flights(){ - Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990); - HashSet flights = new HashSet<>(); - Flight flight1 = mock(Flight.class); - Flight flight2 = mock(Flight.class); - + public void test_getFlights_wiht_2_flights() { flights.add(flight1); flights.add(flight2); @@ -59,5 +56,4 @@ public class AircraftTest { } - }