Home / Class/ MavenBuildOutputTimestampTests Class — spring-boot Architecture

MavenBuildOutputTimestampTests Class — spring-boot Architecture

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

Entity Profile

Source Code

build-plugin/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/MavenBuildOutputTimestampTests.java lines 33–100

class MavenBuildOutputTimestampTests {

	@Test
	void shouldParseNull() {
		assertThat(parse(null)).isNull();
	}

	@Test
	void shouldParseSingleDigit() {
		assertThat(parse("0")).isEqualTo(Instant.parse("1970-01-01T00:00:00Z"));
	}

	@Test
	void shouldNotParseSingleCharacter() {
		assertThat(parse("a")).isNull();
	}

	@Test
	void shouldParseIso8601() {
		assertThat(parse("2011-12-03T10:15:30Z")).isEqualTo(Instant.parse("2011-12-03T10:15:30.000Z"));
	}

	@Test
	void shouldParseIso8601WithMilliseconds() {
		assertThat(parse("2011-12-03T10:15:30.123Z")).isEqualTo(Instant.parse("2011-12-03T10:15:30.123Z"));
	}

	@Test
	void shouldFailIfIso8601BeforeMin() {
		assertThatIllegalArgumentException().isThrownBy(() -> parse("1970-01-01T00:00:00Z"))
			.withMessage(
					"'1970-01-01T00:00:00Z' is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z");
	}

	@Test
	void shouldFailIfIso8601AfterMax() {
		assertThatIllegalArgumentException().isThrownBy(() -> parse("2100-01-01T00:00:00Z"))
			.withMessage(
					"'2100-01-01T00:00:00Z' is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z");
	}

	@Test
	void shouldFailIfNotIso8601() {
		assertThatIllegalArgumentException().isThrownBy(() -> parse("dummy"))
			.withMessage("Can't parse 'dummy' to instant");
	}

	@Test
	void shouldParseIso8601WithOffset() {
		assertThat(parse("2019-10-05T20:37:42+06:00")).isEqualTo(Instant.parse("2019-10-05T14:37:42Z"));
	}

	@Test
	void shouldParseToFileTime() {
		assertThat(parseFileTime(null)).isEqualTo(null);
		assertThat(parseFileTime("0")).isEqualTo(FileTime.fromMillis(0));
		assertThat(parseFileTime("2019-10-05T14:37:42Z")).isEqualTo(FileTime.fromMillis(1570286262000L));
	}

	private static @Nullable Instant parse(@Nullable String timestamp) {
		return new MavenBuildOutputTimestamp(timestamp).toInstant();
	}

	private static @Nullable FileTime parseFileTime(@Nullable String timestamp) {
		return new MavenBuildOutputTimestamp(timestamp).toFileTime();
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free