|
@ -4,6 +4,8 @@ import org.junit.Assert; |
|
|
import org.junit.jupiter.api.DisplayName; |
|
|
import org.junit.jupiter.api.DisplayName; |
|
|
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.junit.jupiter.params.ParameterizedTest; |
|
|
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
import org.mockito.InjectMocks; |
|
|
import org.mockito.InjectMocks; |
|
|
import org.mockito.Mock; |
|
|
import org.mockito.Mock; |
|
|
|
|
|
|
|
@ -11,7 +13,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows; |
|
|
import static org.mockito.Mockito.*; |
|
|
import static org.mockito.Mockito.*; |
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
@ -60,6 +66,23 @@ public class ItineraryTest { |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
msg = e.getMessage(); |
|
|
msg = e.getMessage(); |
|
|
} |
|
|
} |
|
|
assertEquals(msg, "Name cannot be null or empty"); |
|
|
|
|
|
|
|
|
assertEquals("Name cannot be null or empty", msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@DisplayName("Should Not Make Reservation when Passenger passport number is invalid") |
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("passportNumberList") |
|
|
|
|
|
public void shouldThrowRuntimeExceptionWhenPhoneNumberIsNull(String passportNumber){ |
|
|
|
|
|
String msg = null; |
|
|
|
|
|
try { |
|
|
|
|
|
item1.makeReservation(new Passenger("John", passportNumber, new Date())); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
msg = e.getMessage(); |
|
|
|
|
|
} |
|
|
|
|
|
assertEquals("Passport number cannot be null or empty", msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static List<String> passportNumberList() { |
|
|
|
|
|
return Arrays.asList("A2", "000000", "AB231837%8"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |