|
@ -1,13 +1,20 @@ |
|
|
package hs.fulda.de.ci.exam.project; |
|
|
package hs.fulda.de.ci.exam.project; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
import org.mockito.InjectMocks; |
|
|
import org.mockito.InjectMocks; |
|
|
import org.mockito.Mock; |
|
|
import org.mockito.Mock; |
|
|
|
|
|
import org.mockito.MockitoAnnotations; |
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.CoreMatchers.is; |
|
|
|
|
|
import static org.hamcrest.CoreMatchers.notNullValue; |
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
|
|
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
import static org.mockito.Mockito.when; |
|
|
import static org.mockito.Mockito.when; |
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
@ExtendWith(MockitoExtension.class) |
|
@ -18,6 +25,11 @@ public class AdminTest { |
|
|
@InjectMocks |
|
|
@InjectMocks |
|
|
Admin admin = new Admin("Max Muster", address1, "example@gmail.com", "012345678" ); |
|
|
Admin admin = new Admin("Max Muster", address1, "example@gmail.com", "012345678" ); |
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
|
public void setUp() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
MockitoAnnotations.initMocks(this); |
|
|
|
|
|
} |
|
|
@Mock |
|
|
@Mock |
|
|
private AccountRepository accountRepository; |
|
|
private AccountRepository accountRepository; |
|
|
|
|
|
|
|
@ -31,4 +43,29 @@ public class AdminTest { |
|
|
|
|
|
|
|
|
assertEquals(Account.AccountStatus.BLOCKED, user.getStatus(), "Status successfully changed"); |
|
|
assertEquals(Account.AccountStatus.BLOCKED, user.getStatus(), "Status successfully changed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Mock |
|
|
|
|
|
private FlightRepository flightRepository; |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void test_addFlight_returnsNewFlight() throws IOException { |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
when(flightRepository.save(any(Flight.class))).thenReturn(true); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
admin.addFlight("1", airport_fr, airport1_ist, 140); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
assertNotNull(admin.addFlight("1", airport_fr, airport1_ist, 140)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |