Home / Class/ DurationToNumberConverterTests Class — spring-boot Architecture

DurationToNumberConverterTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/convert/DurationToNumberConverterTests.java lines 35–61

class DurationToNumberConverterTests {

	@ConversionServiceTest
	void convertWithoutStyleShouldReturnMs(ConversionService conversionService) {
		Long converted = conversionService.convert(Duration.ofSeconds(1), Long.class);
		assertThat(converted).isEqualTo(1000);
	}

	@ConversionServiceTest
	void convertWithFormatShouldUseIgnoreFormat(ConversionService conversionService) {
		Integer converted = (Integer) conversionService.convert(Duration.ofSeconds(1),
				MockDurationTypeDescriptor.get(null, DurationStyle.ISO8601), TypeDescriptor.valueOf(Integer.class));
		assertThat(converted).isEqualTo(1000);
	}

	@ConversionServiceTest
	void convertWithFormatAndUnitShouldUseFormatAndUnit(ConversionService conversionService) {
		Byte converted = (Byte) conversionService.convert(Duration.ofSeconds(1),
				MockDurationTypeDescriptor.get(ChronoUnit.SECONDS, null), TypeDescriptor.valueOf(Byte.class));
		assertThat(converted).isEqualTo((byte) 1);
	}

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

}

Analyze Your Own Codebase

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

Try Supermodel Free