Home / Class/ DurationToStringConverterTests Class — spring-boot Architecture

DurationToStringConverterTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/convert/DurationToStringConverterTests.java lines 35–62

class DurationToStringConverterTests {

	@ConversionServiceTest
	void convertWithoutStyleShouldReturnIso8601(ConversionService conversionService) {
		String converted = conversionService.convert(Duration.ofSeconds(1), String.class);
		assertThat(converted).isEqualTo("PT1S");
	}

	@ConversionServiceTest
	void convertWithFormatShouldUseFormatAndMs(ConversionService conversionService) {
		String converted = (String) conversionService.convert(Duration.ofSeconds(1),
				MockDurationTypeDescriptor.get(null, DurationStyle.SIMPLE), TypeDescriptor.valueOf(String.class));
		assertThat(converted).isEqualTo("1000ms");
	}

	@ConversionServiceTest
	void convertWithFormatAndUnitShouldUseFormatAndUnit(ConversionService conversionService) {
		String converted = (String) conversionService.convert(Duration.ofSeconds(1),
				MockDurationTypeDescriptor.get(ChronoUnit.SECONDS, DurationStyle.SIMPLE),
				TypeDescriptor.valueOf(String.class));
		assertThat(converted).isEqualTo("1s");
	}

	static Stream<? extends Arguments> conversionServices() {
		return ConversionServiceArguments.with(new DurationToStringConverter());
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free