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
public void whenNotNullName_thenNoConstraintViolations() {
UserNotNull user = new UserNotNull("John");
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0);
}
@Test
public void whenNullName_thenOneConstraintViolation() {
UserNotNull user = new UserNotNull(null);
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(1);
}
@Test
public void whenEmptyName_thenNoConstraintViolations() {
UserNotNull user = new UserNotNull("");
Set<ConstraintViolation<UserNotNull>> violations = validator.validate(user);
assertThat(violations.size()).isEqualTo(0);
}
@Test
public void whenToString_thenCorrect() {
UserNotNull user = new UserNotNull("John");
assertThat(user.toString()).isEqualTo("User{name=John}");
}
}