Home / Class/ InetAddressFormatterTests Class — spring-boot Architecture

InetAddressFormatterTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/convert/InetAddressFormatterTests.java lines 37–79

class InetAddressFormatterTests {

	@ConversionServiceTest
	void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) {
		assumingThat(isResolvable("example.com"), () -> {
			InetAddress address = InetAddress.getByName("example.com");
			String converted = conversionService.convert(address, String.class);
			assertThat(converted).isEqualTo(address.getHostAddress());
		});
	}

	@ConversionServiceTest
	void convertFromStringToInetAddressShouldConvert(ConversionService conversionService) {
		assumingThat(isResolvable("example.com"), () -> {
			InetAddress converted = conversionService.convert("example.com", InetAddress.class);
			assertThat(converted).isNotNull();
			assertThat(converted.toString()).startsWith("example.com");
		});
	}

	@ConversionServiceTest
	void convertFromStringToInetAddressWhenHostDoesNotExistShouldThrowException(ConversionService conversionService) {
		String missingDomain = "ireallydontexist.example.com";
		assumingThat(!isResolvable("ireallydontexist.example.com"),
				() -> assertThatExceptionOfType(ConversionFailedException.class)
					.isThrownBy(() -> conversionService.convert(missingDomain, InetAddress.class)));
	}

	private boolean isResolvable(String host) {
		try {
			InetAddress.getByName(host);
			return true;
		}
		catch (UnknownHostException ex) {
			return false;
		}
	}

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

}

Analyze Your Own Codebase

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

Try Supermodel Free