Home / Class/ ConfigurationPropertyTests Class — spring-boot Architecture

ConfigurationPropertyTests Class — spring-boot Architecture

Architecture documentation for the ConfigurationPropertyTests class in ConfigurationPropertyTests.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyTests.java lines 37–100

class ConfigurationPropertyTests {

	private static final ConfigurationPropertyName NAME = ConfigurationPropertyName.of("foo");

	private final ConfigurationPropertySource source = Objects
		.requireNonNull(ConfigurationPropertySource.from(mock(PropertySource.class)));

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void createWhenNameIsNullShouldThrowException() {
		assertThatIllegalArgumentException().isThrownBy(() -> new ConfigurationProperty(null, "bar", null))
			.withMessageContaining("'name' must not be null");
	}

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void createWhenValueIsNullShouldThrowException() {
		assertThatIllegalArgumentException().isThrownBy(() -> new ConfigurationProperty(NAME, null, null))
			.withMessageContaining("'value' must not be null");
	}

	@Test
	void getNameShouldReturnName() {
		ConfigurationProperty property = ConfigurationProperty.of(this.source, NAME, "foo", null);
		assertThat((Object) property.getName()).isEqualTo(NAME);
	}

	@Test
	void getValueShouldReturnValue() {
		ConfigurationProperty property = ConfigurationProperty.of(this.source, NAME, "foo", null);
		assertThat(property.getValue()).isEqualTo("foo");
	}

	@Test
	void getPropertyOriginShouldReturnValuePropertyOrigin() {
		Origin origin = mock(Origin.class);
		OriginProvider property = ConfigurationProperty.of(this.source, NAME, "foo", origin);
		assertThat(property.getOrigin()).isEqualTo(origin);
	}

	@Test
	void getPropertySourceShouldReturnPropertySource() {
		Origin origin = mock(Origin.class);
		ConfigurationProperty property = ConfigurationProperty.of(this.source, NAME, "foo", origin);
		assertThat(property.getSource()).isEqualTo(this.source);
	}

	@Test
	void equalsAndHashCode() {
		ConfigurationProperty property1 = new ConfigurationProperty(ConfigurationPropertyName.of("foo"), "bar", null);
		ConfigurationProperty property2 = new ConfigurationProperty(ConfigurationPropertyName.of("foo"), "bar", null);
		ConfigurationProperty property3 = new ConfigurationProperty(ConfigurationPropertyName.of("foo"), "baz", null);
		ConfigurationProperty property4 = new ConfigurationProperty(ConfigurationPropertyName.of("baz"), "bar", null);
		assertThat(property1).hasSameHashCodeAs(property2);
		assertThat(property1).isEqualTo(property2).isNotEqualTo(property3).isNotEqualTo(property4);
	}

	@Test
	void toStringShouldReturnValue() {
		ConfigurationProperty property = ConfigurationProperty.of(this.source, NAME, "foo", null);
		assertThat(property.toString()).contains("name").contains("value");
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free