Home / Class/ AlwaysTests Class — spring-boot Architecture

AlwaysTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java lines 266–310

	@Nested
	class AlwaysTests {

		private final PropertyMapper map = PropertyMapperTests.this.map;

		@Test
		void asWhenNull() {
			String value = this.map.from((String) null).always().as(String::valueOf).toInstance((string) -> {
				assertThat(string).isNotNull();
				return string;
			});
			assertThat(value).isEqualTo("null");
		}

		@Test
		void toConsumerWhenNull() {
			ExampleDest dest = new ExampleDest();
			this.map.from((String) null).always().to(dest::setName);
			assertThat(dest.getName()).isNull();
			assertThat(dest.setNameCalled).isTrue();
		}

		@Test
		void toImmutableWhenNull() {
			Immutable instance = this.map.from("Spring").toInstance(Immutable::of);
			instance = this.map.from((Integer) null).always().to(instance, Immutable::withAge);
			assertThat(instance).hasToString("Spring null");
			assertThat(instance.withAgeCalled).isTrue();
		}

		@Test
		void toInstanceWhenNull() {
			String value = this.map.from((String) null).always().toInstance(String::valueOf);
			assertThat(value).isEqualTo("null");
		}

		@Test
		void toCallWhenNull() {
			AtomicBoolean called = new AtomicBoolean();
			Runnable call = () -> called.set(true);
			this.map.from((String) null).always().toCall(call);
			assertThat(called).isTrue();
		}

	}

Analyze Your Own Codebase

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

Try Supermodel Free