Update UserNotNullUnitTest.java

This commit is contained in:
Alejandro Gervasio
2018-09-25 01:24:09 -03:00
committed by GitHub
parent 2518a07d93
commit c8e54a21c0

View File

@@ -21,27 +21,34 @@ public class UserNotNullUnitTest {
@Test @Test
public void whenNotNullName_thenNoConstraintViolations() { public void whenNotNullName_thenNoConstraintViolations() {
UserNotNull user = new UserNotNull("John"); UserNotNull user = new UserNotNull("John");
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user); Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0); assertThat(violations.size()).isEqualTo(0);
} }
@Test @Test
public void whenNullName_thenOneConstraintViolation() { public void whenNullName_thenOneConstraintViolation() {
UserNotNull user = new UserNotNull(null); UserNotNull user = new UserNotNull(null);
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user); Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1); assertThat(violations.size()).isEqualTo(1);
} }
@Test @Test
public void whenEmptyName_thenNoConstraintViolations() { public void whenEmptyName_thenNoConstraintViolations() {
UserNotNull user = new UserNotNull(""); UserNotNull user = new UserNotNull("");
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user); Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0); assertThat(violations.size()).isEqualTo(0);
} }
@Test @Test
public void whenToString_thenCorrect() { public void whenToString_thenCorrect() {
UserNotNull user = new UserNotNull("John"); UserNotNull user = new UserNotNull("John");
assertThat(user.toString()).isEqualTo("User{name=John}"); assertThat(user.toString()).isEqualTo("User{name=John}");
} }
} }