ValidationErrorsTests Class — spring-boot Architecture
Architecture documentation for the ValidationErrorsTests class in ValidationErrorsTests.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/validation/ValidationErrorsTests.java lines 43–116
class ValidationErrorsTests {
private static final ConfigurationPropertyName NAME = ConfigurationPropertyName.of("foo");
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenNameIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ValidationErrors(null, Collections.emptySet(), Collections.emptyList()))
.withMessageContaining("'name' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenBoundPropertiesIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ValidationErrors(NAME, null, Collections.emptyList()))
.withMessageContaining("'boundProperties' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenErrorsIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ValidationErrors(NAME, Collections.emptySet(), null))
.withMessageContaining("'errors' must not be null");
}
@Test
void getNameShouldReturnName() {
ConfigurationPropertyName name = NAME;
ValidationErrors errors = new ValidationErrors(name, Collections.emptySet(), Collections.emptyList());
assertThat((Object) errors.getName()).isEqualTo(name);
}
@Test
void getBoundPropertiesShouldReturnBoundProperties() {
Set<ConfigurationProperty> boundProperties = new LinkedHashSet<>();
boundProperties.add(new ConfigurationProperty(NAME, "foo", null));
ValidationErrors errors = new ValidationErrors(NAME, boundProperties, Collections.emptyList());
assertThat(errors.getBoundProperties()).isEqualTo(boundProperties);
}
@Test
void getErrorsShouldReturnErrors() {
List<ObjectError> allErrors = new ArrayList<>();
allErrors.add(new ObjectError("foo", "bar"));
ValidationErrors errors = new ValidationErrors(NAME, Collections.emptySet(), allErrors);
assertThat(errors.getAllErrors()).isEqualTo(allErrors);
}
@Test
void iteratorShouldIterateErrors() {
List<ObjectError> allErrors = new ArrayList<>();
allErrors.add(new ObjectError("foo", "bar"));
ValidationErrors errors = new ValidationErrors(NAME, Collections.emptySet(), allErrors);
assertThat(errors.iterator()).toIterable().containsExactlyElementsOf(allErrors);
}
@Test
void getErrorsShouldAdaptFieldErrorsToBeOriginProviders() {
Set<ConfigurationProperty> boundProperties = new LinkedHashSet<>();
ConfigurationPropertyName name1 = ConfigurationPropertyName.of("foo.bar");
Origin origin1 = MockOrigin.of("line1");
boundProperties.add(new ConfigurationProperty(name1, "boot", origin1));
ConfigurationPropertyName name2 = ConfigurationPropertyName.of("foo.baz.bar");
Origin origin2 = MockOrigin.of("line2");
boundProperties.add(new ConfigurationProperty(name2, "boot", origin2));
List<ObjectError> allErrors = new ArrayList<>();
allErrors.add(new FieldError("objectname", "bar", "message"));
ValidationErrors errors = new ValidationErrors(ConfigurationPropertyName.of("foo.baz"), boundProperties,
allErrors);
assertThat(Origin.from(errors.getAllErrors().get(0))).isEqualTo(origin2);
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free