diff --git a/src/test/java/com/fewlaps/quitnowemailsuggester/EmailPartsTest.java b/src/test/java/com/fewlaps/quitnowemailsuggester/EmailPartsTest.java index d035f8d..5065069 100644 --- a/src/test/java/com/fewlaps/quitnowemailsuggester/EmailPartsTest.java +++ b/src/test/java/com/fewlaps/quitnowemailsuggester/EmailPartsTest.java @@ -62,4 +62,58 @@ public void shouldReturnGmail() throws InvalidEmailException { public void shouldReturnHitmail() throws InvalidEmailException { assertEquals("hitmail", ep.getDomainWithoutTld("roc@hitmail.it")); } + + @Test + public void shouldLaunchAnInvalidEmailExceptionForNullAtGetTld() throws InvalidEmailException { + try { + ep.getTld(null); + } catch (InvalidEmailException e) { + return; //This is what we expect + } + } + + @Test + public void shouldLaunchAnInvalidEmailExceptionForNopeAtGetTld() throws InvalidEmailException { + try { + ep.getTld("nope"); + } catch (InvalidEmailException e) { + return; //This is what we expect + } + } + + @Test + public void shouldLaunchAnInvalidEmailExceptionForNullAtGetDomain() throws InvalidEmailException { + try { + ep.getDomain(null); + } catch (InvalidEmailException e) { + return; //This is what we expect + } + } + + @Test + public void shouldLaunchAnInvalidEmailExceptionForNopeAtGetDomain() throws InvalidEmailException { + try { + ep.getDomain("nope"); + } catch (InvalidEmailException e) { + return; //This is what we expect + } + } + + @Test + public void shouldLaunchAnInvalidEmailExceptionForNullAtGetDomainWoTld() throws InvalidEmailException { + try { + ep.getDomainWithoutTld(null); + } catch (InvalidEmailException e) { + return; //This is what we expect + } + } + + @Test + public void shouldLaunchAnInvalidEmailExceptionForNopeAtGetDomainWoTld() throws InvalidEmailException { + try { + ep.getDomainWithoutTld("nope"); + } catch (InvalidEmailException e) { + return; //This is what we expect + } + } }