SW360MetaDataUpdater { public SW360Release deleteAttachments(SW360Release release, Predicate<SW360SparseAttachment> filter) { Set<String> deleteAttachmentIds = release.getEmbedded().getAttachments().stream() .filter(filter) .map(SW360SparseAttachment::getId) .collect(Collectors.toSet()); return deleteAttachmentIds.isEmpty() ? release : releaseClientAdapter.deleteAttachments(release, deleteAttachmentIds); } SW360MetaDataUpdater(SW360Connection connection); Set<SW360License> getLicenses(Collection<License> licenses); SW360Release getOrCreateRelease(SW360Release sw360ReleaseFromArtifact, boolean updateExisting); void createProject(String projectName, String projectVersion, Collection<SW360Release> releases); AttachmentUploadResult<SW360Release> uploadAttachments(SW360Release sw360Release,
                                                                  Map<Path, SW360AttachmentType> attachments,
                                                                  boolean force); SW360Release deleteSourceAttachments(SW360Release release); SW360Release deleteAttachments(SW360Release release, Predicate<SW360SparseAttachment> filter);  }
@Test public void testDeleteSpecificAttachment() { SW360SparseAttachment attachment1 = createAttachment("source1", SW360AttachmentType.SOURCE); SW360SparseAttachment attachment2 = createAttachment("source2", SW360AttachmentType.SOURCE); SW360Release release = addAttachment(addAttachment(createRelease(RELEASE_NAME), attachment1), attachment2); SW360Release updatedRelease = addAttachment(createRelease(RELEASE_NAME), attachment2); when(releaseClientAdapter.deleteAttachments(release, Collections.singleton(attachment1.getId()))) .thenReturn(updatedRelease); SW360Release result = metaDataUpdater.deleteAttachments(release, attachment -> attachment1.getFilename().equals(attachment.getFilename())); assertThat(result).isEqualTo(updatedRelease); }