Skip to content

Commit

Permalink
Testing that EmailParts launches exceptions for nulls and invalid emails
Browse files Browse the repository at this point in the history
  • Loading branch information
rocboronat committed Sep 15, 2015
1 parent 7c18d68 commit 2be1b69
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,58 @@ public void shouldReturnGmail() throws InvalidEmailException {
public void shouldReturnHitmail() throws InvalidEmailException {
assertEquals("hitmail", ep.getDomainWithoutTld("[email protected]"));
}

@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
}
}
}

0 comments on commit 2be1b69

Please sign in to comment.