You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.6 KiB
70 lines
2.6 KiB
package hs.fulda.de.ci.exam.project;
|
|
|
|
import org.junit.jupiter.api.DisplayName;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
import org.junit.jupiter.params.ParameterizedTest;
|
|
import org.junit.jupiter.params.provider.ValueSource;
|
|
import org.mockito.InjectMocks;
|
|
import org.mockito.Mock;
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
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;
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
public class PersonTest {
|
|
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");
|
|
|
|
Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
|
|
@InjectMocks
|
|
Person person1 = new Person("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206");
|
|
|
|
@Mock
|
|
private FlightRepository flightRepository;
|
|
|
|
@Test
|
|
void test_getName() {
|
|
assertThat(person1.getName()).describedAs("get person name").isEqualTo("Max Mustermann");
|
|
}
|
|
|
|
@Test
|
|
void test_getAddress() {
|
|
assertThat(person1.getAddress()).describedAs("get address of person").isEqualTo(address1);
|
|
}
|
|
|
|
@Test
|
|
void test_getEmail() {
|
|
assertThat(person1.getEmail()).describedAs("get person email").isEqualTo("max.mustermann@gmail.com");
|
|
}
|
|
@Test
|
|
void test_getPhone() {
|
|
assertThat(person1.getPhone()).describedAs("get person phone").isEqualTo("015147890206");
|
|
}
|
|
|
|
@Test
|
|
public void test_searchAllFlightsByCriteria(){
|
|
ArrayList<String> flights = new ArrayList<>();
|
|
flights.add("Flight1");
|
|
when(flightRepository.findbyDepartureArrival(airport_fr, airport1_ist)).thenReturn(flights);
|
|
assertNotNull(person1.searchAllFlightsByCriteria(airport_fr, airport1_ist));
|
|
}
|
|
|
|
@Test
|
|
public void test_searchFlight(){
|
|
Flight flight1 = new Flight("1", airport_fr, airport1_ist, 140);
|
|
when(flightRepository.findFlightByFlightNumber(any(String.class))).thenReturn(flight1.toString());
|
|
assertNotNull(person1.searchFlights("1"));
|
|
assertEquals(person1.searchFlights("1"), flight1.toString());
|
|
}
|
|
}
|