Validator { public static boolean isEmailAddressValid(String emailAddress) { return Pattern .compile(".+@.+") .matcher(emailAddress) .matches(); } private  Validator(); static boolean isEmailAddressValid(String emailAddress); static boolean isUrlValid(String url);  }
@Test public void emailValidationTestCase() { assertTrue(Validator.isEmailAddressValid("prettyandsimple@example.com")); assertTrue(Validator.isEmailAddressValid("very.common@example.com")); assertTrue(Validator.isEmailAddressValid("disposable.style.email.with+symbol@example.com")); assertTrue(Validator.isEmailAddressValid("other.email-with-dash@example.com")); assertTrue(Validator.isEmailAddressValid("fully-qualified-domain@example.com.")); assertTrue(Validator.isEmailAddressValid("x@example.com")); assertTrue(Validator.isEmailAddressValid("\"very.unusual.@.unusual.com\"@example.com")); assertTrue(Validator.isEmailAddressValid("\"very.(),:;<>[]\\\".VERY.\\\"very@\\\\ \\\"very\\\".unusual\"@strange.example.com")); assertTrue(Validator.isEmailAddressValid("example-indeed@strange-example.com")); assertTrue(Validator.isEmailAddressValid("admin@mailserver1")); assertTrue(Validator.isEmailAddressValid("#!$%&'*+-/=?^_`{}|~@example.org")); assertTrue(Validator.isEmailAddressValid("\"()<>[]:,;@\\\\\\\"!#$%&'-/=?^_`{}| ~.a\"@example.org")); assertTrue(Validator.isEmailAddressValid("\" \"@example.org")); assertTrue(Validator.isEmailAddressValid("example@s.solutions")); assertTrue(Validator.isEmailAddressValid("user@localserver")); assertTrue(Validator.isEmailAddressValid("user@[IPv6:2001:DB8::1")); assertFalse(Validator.isEmailAddressValid("plainaddress")); assertFalse(Validator.isEmailAddressValid("@domain.com")); assertFalse(Validator.isEmailAddressValid("@")); assertFalse(Validator.isEmailAddressValid("email@")); assertFalse(Validator.isEmailAddressValid("email.domain.com")); }