@Test public void testCreateProjectWithProjectPresent() { final String projectName = "projectName"; final String projectVersion = "projectVersion"; final String projectId = "12345"; SW360Project project = new SW360Project(); project.getLinks().setSelf(new Self("https: when(projectClientAdapter.getProjectByNameAndVersion(projectName, projectVersion)) .thenReturn(Optional.of(project)); metaDataUpdater.createProject(projectName, projectVersion, Collections.emptySet()); verify(projectClientAdapter, never()).createProject(any()); verify(projectClientAdapter, times(1)).addSW360ReleasesToSW360Project(projectId, Collections.emptySet()); }
public void createProject(String projectName, String projectVersion, Collection<SW360Release> releases) { Optional<String> projectId = projectClientAdapter.getProjectByNameAndVersion(projectName, projectVersion) .map(SW360HalResource::getId); String id = projectId.orElseGet(() -> projectClientAdapter.createProject(prepareNewProject(projectName, projectVersion)).getId()); projectClientAdapter.addSW360ReleasesToSW360Project(id, releases); }
SW360MetaDataUpdater { public void createProject(String projectName, String projectVersion, Collection<SW360Release> releases) { Optional<String> projectId = projectClientAdapter.getProjectByNameAndVersion(projectName, projectVersion) .map(SW360HalResource::getId); String id = projectId.orElseGet(() -> projectClientAdapter.createProject(prepareNewProject(projectName, projectVersion)).getId()); projectClientAdapter.addSW360ReleasesToSW360Project(id, releases); } }
SW360MetaDataUpdater { public void createProject(String projectName, String projectVersion, Collection<SW360Release> releases) { Optional<String> projectId = projectClientAdapter.getProjectByNameAndVersion(projectName, projectVersion) .map(SW360HalResource::getId); String id = projectId.orElseGet(() -> projectClientAdapter.createProject(prepareNewProject(projectName, projectVersion)).getId()); projectClientAdapter.addSW360ReleasesToSW360Project(id, releases); } SW360MetaDataUpdater(SW360Connection connection); }
SW360MetaDataUpdater { public void createProject(String projectName, String projectVersion, Collection<SW360Release> releases) { Optional<String> projectId = projectClientAdapter.getProjectByNameAndVersion(projectName, projectVersion) .map(SW360HalResource::getId); String id = projectId.orElseGet(() -> projectClientAdapter.createProject(prepareNewProject(projectName, projectVersion)).getId()); projectClientAdapter.addSW360ReleasesToSW360Project(id, releases); } 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); }
SW360MetaDataUpdater { public void createProject(String projectName, String projectVersion, Collection<SW360Release> releases) { Optional<String> projectId = projectClientAdapter.getProjectByNameAndVersion(projectName, projectVersion) .map(SW360HalResource::getId); String id = projectId.orElseGet(() -> projectClientAdapter.createProject(prepareNewProject(projectName, projectVersion)).getId()); projectClientAdapter.addSW360ReleasesToSW360Project(id, releases); } 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);  }