use of com.github.tomakehurst.wiremock.common.FileSource in project spring-cloud-contract by spring-cloud.
the class ResourcesFileSource method toSources.
private static FileSource[] toSources(Resource[] resources) {
FileSource[] sources = new FileSource[resources.length];
for (int i = 0; i < resources.length; i++) {
Resource resource = resources[i];
if (resource instanceof ClassPathResource) {
ClassPathResource classes = (ClassPathResource) resource;
sources[i] = new ClasspathFileSource(classes.getPath());
} else if (resource instanceof FileSystemResource) {
FileSystemResource files = (FileSystemResource) resource;
sources[i] = new SingleRootFileSource(files.getFile());
} else if (resource instanceof UrlResource) {
sources[i] = fileOrFallbackToClasspath(resource);
} else {
throw new IllegalArgumentException("Unsupported resource type for file source: " + resource.getClass());
}
}
return sources;
}
Aggregations