@Test public void testUpdaterArtifactToReleaseDeleteSources() throws IOException { Path sourceFile = createTestFile(); Artifact artifact = TestUtils.mkArtifact("test", false); artifact.addFact(new ArtifactSourceFile(sourceFile)); SW360Release release = createRelease("test", sourceFile); SW360Release createdRelease = createRelease("testCreated", sourceFile); SW360Release srcDeletedRelease = createRelease("testAttachmentsDeleted", sourceFile); SW360Release updatedRelease = createRelease("testUpdated", sourceFile); Map<Path, SW360AttachmentType> uploadMap = Collections.singletonMap(sourceFile, SW360AttachmentType.SOURCE); AttachmentUploadResult<SW360Release> uploadResult = new AttachmentUploadResult<>(updatedRelease); when(metaDataUpdater.getOrCreateRelease(release, false)) .thenReturn(createdRelease); when(metaDataUpdater.deleteAttachments(eq(createdRelease), any())).thenReturn(srcDeletedRelease); when(metaDataUpdater.uploadAttachments(srcDeletedRelease, uploadMap, true)) .thenReturn(uploadResult); SW360UpdaterImpl updater = new SW360UpdaterImpl(metaDataUpdater, "test", "version", false, true, true); AttachmentUploadResult<SW360Release> result = updater.artifactToReleaseWithUploads(artifact, release, uploadMap); assertThat(result).isEqualTo(uploadResult); Predicate<SW360SparseAttachment> predicate = extractPredicateForDeleteAttachments(createdRelease); assertThat(predicate.test(createAttachment(Paths.get("foo"), SW360AttachmentType.SOURCE))) .isTrue(); assertThat(predicate.test(createAttachment(sourceFile, SW360AttachmentType.SOURCE))) .isFalse(); }
public AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release, Map<Path, SW360AttachmentType> uploads) { Set<String> licenseIds = getSetOfLicenseIds(artifact); release.setMainLicenseIds(licenseIds); SW360Release sw360ReleaseFinal = sw360MetaDataUpdater.getOrCreateRelease(release, isUpdateReleases()); return uploadSourceAndAttachments(sw360ReleaseFinal, artifact, uploads); }
SW360UpdaterImpl { public AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release, Map<Path, SW360AttachmentType> uploads) { Set<String> licenseIds = getSetOfLicenseIds(artifact); release.setMainLicenseIds(licenseIds); SW360Release sw360ReleaseFinal = sw360MetaDataUpdater.getOrCreateRelease(release, isUpdateReleases()); return uploadSourceAndAttachments(sw360ReleaseFinal, artifact, uploads); } }
SW360UpdaterImpl { public AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release, Map<Path, SW360AttachmentType> uploads) { Set<String> licenseIds = getSetOfLicenseIds(artifact); release.setMainLicenseIds(licenseIds); SW360Release sw360ReleaseFinal = sw360MetaDataUpdater.getOrCreateRelease(release, isUpdateReleases()); return uploadSourceAndAttachments(sw360ReleaseFinal, artifact, uploads); } SW360UpdaterImpl(SW360MetaDataUpdater sw360MetaDataUpdater,
                            String projectName, String projectVersion, boolean updateReleases,
                            boolean uploadSources, boolean deleteObsoleteSourceAttachments); }
SW360UpdaterImpl { public AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release, Map<Path, SW360AttachmentType> uploads) { Set<String> licenseIds = getSetOfLicenseIds(artifact); release.setMainLicenseIds(licenseIds); SW360Release sw360ReleaseFinal = sw360MetaDataUpdater.getOrCreateRelease(release, isUpdateReleases()); return uploadSourceAndAttachments(sw360ReleaseFinal, artifact, uploads); } SW360UpdaterImpl(SW360MetaDataUpdater sw360MetaDataUpdater,
                            String projectName, String projectVersion, boolean updateReleases,
                            boolean uploadSources, boolean deleteObsoleteSourceAttachments); boolean isUpdateReleases(); boolean isUploadSources(); boolean isDeleteObsoleteSourceAttachments(); Map<String, IAttachable> produce(Collection<Artifact> intermediates); SW360Release artifactToReleaseInSW360(Artifact artifact); SW360Release artifactToReleaseInSW360(Artifact artifact, SW360Release release); AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release,
                                                                             Map<Path, SW360AttachmentType> uploads); }
SW360UpdaterImpl { public AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release, Map<Path, SW360AttachmentType> uploads) { Set<String> licenseIds = getSetOfLicenseIds(artifact); release.setMainLicenseIds(licenseIds); SW360Release sw360ReleaseFinal = sw360MetaDataUpdater.getOrCreateRelease(release, isUpdateReleases()); return uploadSourceAndAttachments(sw360ReleaseFinal, artifact, uploads); } SW360UpdaterImpl(SW360MetaDataUpdater sw360MetaDataUpdater,
                            String projectName, String projectVersion, boolean updateReleases,
                            boolean uploadSources, boolean deleteObsoleteSourceAttachments); boolean isUpdateReleases(); boolean isUploadSources(); boolean isDeleteObsoleteSourceAttachments(); Map<String, IAttachable> produce(Collection<Artifact> intermediates); SW360Release artifactToReleaseInSW360(Artifact artifact); SW360Release artifactToReleaseInSW360(Artifact artifact, SW360Release release); AttachmentUploadResult<SW360Release> artifactToReleaseWithUploads(Artifact artifact, SW360Release release,
                                                                             Map<Path, SW360AttachmentType> uploads);  }