Update UserNotBlankUnitTest.java
This commit is contained in:
parent
2e92e272ad
commit
81b34c7628
|
@ -21,34 +21,43 @@ public class UserNotBlankUnitTest {
|
|||
@Test
|
||||
public void whenNotBlankName_thenNoConstraintViolations() {
|
||||
UserNotBlank user = new UserNotBlank("John");
|
||||
|
||||
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
|
||||
|
||||
assertThat(violations.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenBlankName_thenOneConstraintViolation() {
|
||||
UserNotBlank user = new UserNotBlank(" ");
|
||||
|
||||
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
|
||||
|
||||
assertThat(violations.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmptyName_thenOneConstraintViolation() {
|
||||
UserNotBlank user = new UserNotBlank("");
|
||||
|
||||
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
|
||||
|
||||
assertThat(violations.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenNullName_thenOneConstraintViolation() {
|
||||
UserNotBlank user = new UserNotBlank(null);
|
||||
|
||||
Set<ConstraintViolation<UserNotBlank>> violations = validator.validate(user);
|
||||
|
||||
assertThat(violations.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenToString_thenCorrect() {
|
||||
UserNotBlank user = new UserNotBlank("John");
|
||||
|
||||
assertThat(user.toString()).isEqualTo("User{name=John}");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue