SW360MetaDataUpdater { public SW360Release deleteSourceAttachments(SW360Release release) { return deleteAttachments(release, attachment -> attachment.getAttachmentType() == SW360AttachmentType.SOURCE); } 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 testDeleteSourceAttachments() { SW360SparseAttachment attachment1 = createAttachment("source1", SW360AttachmentType.SOURCE); SW360SparseAttachment attachment2 = createAttachment("source2", SW360AttachmentType.SOURCE); SW360SparseAttachment attachment3 = createAttachment("other1", SW360AttachmentType.BINARY); SW360SparseAttachment attachment4 = createAttachment("other1", SW360AttachmentType.DOCUMENT); SW360Release release = addAttachment(addAttachment(addAttachment(addAttachment(createRelease(RELEASE_NAME), attachment1), attachment2), attachment3), attachment4); SW360Release updatedRelease = addAttachment(addAttachment(createRelease(RELEASE_NAME), attachment3), attachment4); when(releaseClientAdapter.deleteAttachments(release, new HashSet<>(Arrays.asList(attachment1.getId(), attachment2.getId())))) .thenReturn(updatedRelease); SW360Release result = metaDataUpdater.deleteSourceAttachments(release); assertThat(result).isEqualTo(updatedRelease); }
@Test public void testDeleteSourceAttachmentsNothingToDelete() { SW360Release release = createRelease(RELEASE_NAME); assertThat(metaDataUpdater.deleteSourceAttachments(release)).isEqualTo(release); verifyZeroInteractions(releaseClientAdapter); }