Created
December 17, 2017 00:57
-
-
Save elnur/d4f688a60da31ffe55aa610fd16f6a3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmailAddressPartsExtractorTest { | |
private EmailAddressPartsExtractor extractor = new EmailAddressPartsExtractor(); | |
@Test | |
public void extractUsername() { | |
assertThat(extractor.extractUsername("[email protected]"), is("elnur.blog")); | |
} | |
@Test | |
public void extractHost() { | |
assertThat(extractor.extractHostname("[email protected]"), is("example.com")); | |
} | |
@Test(expected = InvalidEmailAddressException.class) | |
public void failToExtractUsernameFromAddressWithoutAtCharacter() { | |
extractor.extractUsername("elnur.example.com"); | |
} | |
@Test(expected = InvalidEmailAddressException.class) | |
public void failToExtractUsernameFromInvalidAddressWithMoreThanOneAtCharacter() { | |
extractor.extractUsername("elnur@example@com"); | |
} | |
@Test(expected = InvalidEmailAddressException.class) | |
public void failToExtractHostnameFromAddressWithoutAtCharacter() { | |
extractor.extractHostname("elnur.example.com"); | |
} | |
@Test(expected = InvalidEmailAddressException.class) | |
public void failToExtractHostnameFromInvalidAddressWithMoreThanOneAtCharacter() { | |
extractor.extractHostname("elnur@example@com"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment