|
@ -56,16 +56,53 @@ public class AccountTest { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
@DisplayName("Should Not add Account details when Address is null") |
|
|
|
|
|
public void shouldThrowRuntimeExceptionWhenAddressIsNull(){ |
|
|
|
|
|
assertThrows(RuntimeException.class, () -> { |
|
|
|
|
|
account1.addAccountDetails("John", null,"max.mustermann@gmail.com", "0151283290" ); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@DisplayName("Check if the Email is valid") |
|
|
@DisplayName("Check if the Email is valid") |
|
|
@ParameterizedTest |
|
|
@ParameterizedTest |
|
|
@MethodSource("phoneNumberList") |
|
|
@MethodSource("phoneNumberList") |
|
|
public void shouldThrowRuntimeExceptionWhenPhoneNumberIsNull(String phoneNumber){ |
|
|
public void shouldThrowRuntimeExceptionWhenPhoneNumberIsNull(String phoneNumber){ |
|
|
assertThrows(RuntimeException.class, () -> { |
|
|
assertThrows(RuntimeException.class, () -> { |
|
|
account1.addAccountDetails(null, address1,"max.mustermann@gmail.com", phoneNumber); |
|
|
|
|
|
|
|
|
account1.addAccountDetails("John", address1,"max.mustermann@gmail.com", phoneNumber); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static List<String> phoneNumberList() { |
|
|
private static List<String> phoneNumberList() { |
|
|
return Arrays.asList("1234567", "0123", "0125314622696456", "0abnajf"); |
|
|
return Arrays.asList("1234567", "0123", "0125314622696456", "0abnajf"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
@DisplayName("Should Not add Account details when Email is blank") |
|
|
|
|
|
public void shouldThrowRuntimeExceptionWhenEmailIsNull(){ |
|
|
|
|
|
assertThrows(RuntimeException.class, () -> { |
|
|
|
|
|
account1.addAccountDetails("John", address1," ", "0151283290" ); |
|
|
|
|
|
}); |
|
|
|
|
|
assertThrows(RuntimeException.class, () -> { |
|
|
|
|
|
account1.addAccountDetails("John", address1,null, "0151283290" ); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("EmailList") |
|
|
|
|
|
@DisplayName("Should Not add Account details when Email Address is not valid") |
|
|
|
|
|
public void shouldThrowRuntimeExceptionWhenEmailIsInvalid(String email){ |
|
|
|
|
|
try{ |
|
|
|
|
|
account1.addAccountDetails("John", address1, email, "0151283290"); |
|
|
|
|
|
} |
|
|
|
|
|
catch(final RuntimeException e){ |
|
|
|
|
|
String msg2 = "Email address is not Valid"; |
|
|
|
|
|
assertEquals(msg2, e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static List<String> EmailList() { |
|
|
|
|
|
return Arrays.asList("max.musterman", "12245.com"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |