@Test
public void testPathsAreSanitizedForDownload() {

    SW360Release release = new SW360Release();
    release.setName("a \"complex\" *release*/name?! -with >0 #special.characters+");
    release.setVersion("10%");
    SW360SparseAttachment attachment = createAttachment(1, 2);
    attachment.setFilename("strange/file\\.txt");
    Set<SW360SparseAttachment> sourceAttachments = Collections.singleton(attachment);
    initAttachments(release, sourceAttachments);
    expectDownloads(release, sourceAttachments);
    Collection<ReleaseWithSources> result =
            sourcesExporter.downloadSources(releaseAdapter, Collections.singleton(release));
    assertThat(result).hasSize(1);
    ArgumentCaptor<SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolderWithParents> captor =
            ArgumentCaptor.forClass(SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolderWithParents.class);
    verify(releaseAdapter).processAttachment(eq(release), eq(attachment.getAttachmentId()), captor.capture());
    SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolderWithParents processor = captor.getValue();
    Path expPath = sourcePath.resolve("a__complex___release__name___-with__0__special.characters_").resolve("10_");
    assertThat(processor.getDownloadPath()).isEqualTo(expPath);
    assertThat(processor.getFileName()).isEqualTo("strange_file_.txt");
}