From e9d9f662e83de8f26e4f35539dfb52fa8954a639 Mon Sep 17 00:00:00 2001 From: Sona Markosyan Date: Tue, 8 Feb 2022 22:36:16 +0100 Subject: [PATCH] account details phone number validation --- .../fulda/de/ci/exam/project/AccountTest.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java index e757a98..0e2f4ec 100644 --- a/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java +++ b/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java @@ -2,12 +2,17 @@ package hs.fulda.de.ci.exam.project; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +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 java.util.Arrays; import java.util.Date; +import java.util.List; import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -44,10 +49,23 @@ public class AccountTest { } @Test - @DisplayName("Should Not Create Itinerary when Starting Airport is null") + @DisplayName("Should Not add Account details when Person Name is null") public void shouldThrowRuntimeExceptionWhenPersonNameIsNull(){ + assertThrows(RuntimeException.class, () -> { + account1.addAccountDetails(null, address1,"max.mustermann@gmail.com", "0151283290" ); + }); + } + + @DisplayName("Check if the Email is valid") + @ParameterizedTest + @MethodSource("phoneNumberList") + public void shouldThrowRuntimeExceptionWhenPhoneNumberIsNull(String phoneNumber){ assertThrows(RuntimeException.class, () -> { - account1.addAccountDetails(null, address1,"max.mustermann@gmail.com", "015147890206" ); + account1.addAccountDetails(null, address1,"max.mustermann@gmail.com", phoneNumber); }); } + + private static List phoneNumberList() { + return Arrays.asList("1234567", "0123", "0125314622696456", "0abnajf"); + } }