Home / Class/ ApplicationInfoPropertySourceTests Class — spring-boot Architecture

ApplicationInfoPropertySourceTests Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/test/java/org/springframework/boot/ApplicationInfoPropertySourceTests.java lines 36–76

class ApplicationInfoPropertySourceTests {

	@Test
	void shouldAddVersion() {
		MockEnvironment environment = new MockEnvironment();
		environment.getPropertySources().addLast(new ApplicationInfoPropertySource("1.2.3"));
		assertThat(environment.getProperty("spring.application.version")).isEqualTo("1.2.3");
	}

	@Test
	void shouldNotAddVersionIfVersionIsNotAvailable() {
		MockEnvironment environment = new MockEnvironment();
		environment.getPropertySources().addLast(new ApplicationInfoPropertySource((String) null));
		assertThat(environment.containsProperty("spring.application.version")).isFalse();
	}

	@Test
	void shouldAddPid() {
		MockEnvironment environment = new MockEnvironment();
		environment.getPropertySources().addLast(new ApplicationInfoPropertySource("1.2.3"));
		assertThat(environment.getProperty("spring.application.pid", Long.class))
			.isEqualTo(new ApplicationPid().toLong());
	}

	@Test
	void shouldMoveToEnd() {
		MockEnvironment environment = new MockEnvironment();
		environment.getPropertySources().addFirst(new MapPropertySource("first", Collections.emptyMap()));
		environment.getPropertySources().addAfter("first", new MapPropertySource("second", Collections.emptyMap()));
		environment.getPropertySources().addFirst(new ApplicationInfoPropertySource("1.2.3"));
		List<String> propertySources = environment.getPropertySources().stream().map(PropertySource::getName).toList();
		assertThat(propertySources).containsExactly("applicationInfo", "first", "second", "mockProperties");
		ApplicationInfoPropertySource.moveToEnd(environment);
		List<String> propertySourcesAfterMove = environment.getPropertySources()
			.stream()
			.map(PropertySource::getName)
			.toList();
		assertThat(propertySourcesAfterMove).containsExactly("first", "second", "mockProperties", "applicationInfo");
	}

}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free