|
|
@ -7,9 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
import org.mockito.InjectMocks; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.MockitoAnnotations; |
|
|
|
import org.mockito.invocation.InvocationOnMock; |
|
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
|
import org.mockito.stubbing.Answer; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
@ -26,9 +24,11 @@ public class AdminTest { |
|
|
|
Airport airport1_ist; |
|
|
|
Flight flight1; |
|
|
|
Address address1; |
|
|
|
Aircraft aircraft; |
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
public void setup() { |
|
|
|
aircraft = new Aircraft("Boeing", "787", 2003); |
|
|
|
address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany"); |
|
|
|
airport_fr = new Airport("Fraport", address_fr, "1234"); |
|
|
|
address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey"); |
|
|
@ -39,11 +39,6 @@ public class AdminTest { |
|
|
|
@InjectMocks |
|
|
|
Admin admin = new Admin("Max Muster", address1, "example@gmail.com", "012345678" ); |
|
|
|
|
|
|
|
@Before |
|
|
|
public void setUp() throws Exception { |
|
|
|
|
|
|
|
MockitoAnnotations.initMocks(this); |
|
|
|
} |
|
|
|
@Mock |
|
|
|
private AccountRepository accountRepository; |
|
|
|
|
|
|
@ -118,4 +113,17 @@ public class AdminTest { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Mock |
|
|
|
private AircraftRepository aircraftRepository; |
|
|
|
|
|
|
|
@Test |
|
|
|
public void test_addAircraft_returnsNewAircraft() throws IOException { |
|
|
|
|
|
|
|
try { |
|
|
|
when(aircraftRepository.save(any(Aircraft.class))).thenReturn(true); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
assertNotNull(admin.addAircraft("Boeing", "787", 2003)); |
|
|
|
} |
|
|
|
} |