StringToFileConverterTests Class — spring-boot Architecture
Architecture documentation for the StringToFileConverterTests class in StringToFileConverterTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/convert/StringToFileConverterTests.java lines 39–76
class StringToFileConverterTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File temp;
@ConversionServiceTest
void convertWhenSimpleFileReturnsFile(ConversionService conversionService) {
assertThat(convert(conversionService, this.temp.getAbsolutePath() + "/test"))
.isEqualTo(new File(this.temp, "test").getAbsoluteFile());
}
@ConversionServiceTest
void convertWhenFilePrefixedReturnsFile(ConversionService conversionService) {
File file = convert(conversionService, "file:" + this.temp.getAbsolutePath() + "/test");
assertThat(file).isNotNull();
assertThat(file.getAbsoluteFile()).isEqualTo(new File(this.temp, "test").getAbsoluteFile());
}
@ConversionServiceTest
@WithResource(name = "com/example/test-file.txt", content = "test content")
void convertWhenClasspathPrefixedReturnsFile(ConversionService conversionService) throws IOException {
String resource = new ClassPathResource("com/example/test-file.txt").getURL().getFile();
File file = convert(conversionService, "classpath:com/example/test-file.txt");
assertThat(file).isNotNull();
assertThat(file.getAbsoluteFile()).isEqualTo(new File(resource).getAbsoluteFile());
}
private @Nullable File convert(ConversionService conversionService, String source) {
return conversionService.convert(source, File.class);
}
static Stream<? extends Arguments> conversionServices() {
return ConversionServiceArguments
.with((conversionService) -> conversionService.addConverter(new StringToFileConverter()));
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free