InactiveConfigDataAccessExceptionTests Class — spring-boot Architecture
Architecture documentation for the InactiveConfigDataAccessExceptionTests class in InactiveConfigDataAccessExceptionTests.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/test/java/org/springframework/boot/context/config/InactiveConfigDataAccessExceptionTests.java lines 39–141
class InactiveConfigDataAccessExceptionTests {
private final MockPropertySource propertySource = new MockPropertySource();
private final ConfigDataResource resource = new TestConfigDataResource();
private final String propertyName = "spring";
private final Origin origin = new PropertySourceOrigin(this.propertySource, this.propertyName);
@Test
void createHasCorrectMessage() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource,
this.resource, this.propertyName, this.origin);
assertThat(exception).hasMessage("Inactive property source 'mockProperties' imported from location 'test' "
+ "cannot contain property 'spring' [origin: \"spring\" from property source \"mockProperties\"]");
}
@Test
void createWhenNoLocationHasCorrectMessage() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource, null,
this.propertyName, this.origin);
assertThat(exception).hasMessage("Inactive property source 'mockProperties' "
+ "cannot contain property 'spring' [origin: \"spring\" from property source \"mockProperties\"]");
}
@Test
void createWhenNoOriginHasCorrectMessage() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource,
this.resource, this.propertyName, null);
assertThat(exception).hasMessage("Inactive property source 'mockProperties' imported from location 'test' "
+ "cannot contain property 'spring'");
}
@Test
void getPropertySourceReturnsPropertySource() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource,
this.resource, this.propertyName, this.origin);
assertThat(exception.getPropertySource()).isSameAs(this.propertySource);
}
@Test
void getLocationReturnsLocation() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource,
this.resource, this.propertyName, this.origin);
assertThat(exception.getLocation()).isSameAs(this.resource);
}
@Test
void getPropertyNameReturnsPropertyName() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource,
this.resource, this.propertyName, this.origin);
assertThat(exception.getPropertyName()).isSameAs(this.propertyName);
}
@Test
void getOriginReturnsOrigin() {
InactiveConfigDataAccessException exception = new InactiveConfigDataAccessException(this.propertySource,
this.resource, this.propertyName, this.origin);
assertThat(exception.getOrigin()).isSameAs(this.origin);
}
@Test
void throwIfPropertyFoundWhenSourceIsNullDoesNothing() {
ConfigDataEnvironmentContributor contributor = mock(ConfigDataEnvironmentContributor.class);
given(contributor.getConfigurationPropertySource()).willReturn(null);
InactiveConfigDataAccessException.throwIfPropertyFound(contributor, ConfigurationPropertyName.of("spring"));
}
@Test
void throwIfPropertyFoundWhenPropertyNotFoundDoesNothing() {
ConfigDataEnvironmentContributor contributor = mock(ConfigDataEnvironmentContributor.class);
ConfigurationPropertySource configurationPropertySource = ConfigurationPropertySource.from(this.propertySource);
given(contributor.getConfigurationPropertySource()).willReturn(configurationPropertySource);
InactiveConfigDataAccessException.throwIfPropertyFound(contributor, ConfigurationPropertyName.of("spring"));
}
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
void throwIfPropertyFoundWhenPropertyFoundThrowsException() {
this.propertySource.setProperty("spring", "test");
ConfigDataEnvironmentContributor contributor = mock(ConfigDataEnvironmentContributor.class);
ConfigurationPropertySource configurationPropertySource = ConfigurationPropertySource.from(this.propertySource);
given(contributor.getConfigurationPropertySource()).willReturn(configurationPropertySource);
given(contributor.getPropertySource()).willReturn((PropertySource) this.propertySource);
given(contributor.getResource()).willReturn(this.resource);
assertThatExceptionOfType(InactiveConfigDataAccessException.class)
.isThrownBy(() -> InactiveConfigDataAccessException.throwIfPropertyFound(contributor,
ConfigurationPropertyName.of("spring")))
.withMessage("Inactive property source 'mockProperties' imported from location 'test' "
+ "cannot contain property 'spring' [origin: \"spring\" from property source \"mockProperties\"]");
}
private static final class TestConfigDataResource extends ConfigDataResource {
@Override
public String toString() {
return "test";
}
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free