use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testCreateProjectWithTwoVersions.
@Test
public void testCreateProjectWithTwoVersions() throws Exception {
// first create a new project with a single version
String projectName = "createWithTwo" + Instant.now().toString();
String projectVersionName = "1.0.0";
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(projectName, projectVersionName);
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
ProjectServiceTestIT.projectService.createProject(projectRequest);
Optional<ProjectVersionWrapper> projectVersionWrapper = ProjectServiceTestIT.projectService.getProjectVersion(projectName, projectVersionName);
ProjectServiceTestIT.project = projectVersionWrapper.get().getProjectView();
List<ProjectVersionView> projectVersionViews = ProjectServiceTestIT.blackDuckApiClient.getAllResponses(ProjectServiceTestIT.project.metaVersionsLink());
assertEquals(1, projectVersionViews.size());
Optional<ProjectVersionView> latestProjectVersionView = ProjectServiceTestIT.projectService.getNewestProjectVersion(ProjectServiceTestIT.project);
assertTrue(latestProjectVersionView.isPresent());
assertEquals("1.0.0", latestProjectVersionView.get().getVersionName());
ProjectVersionRequest projectVersionRequest = projectRequest.getVersionRequest();
projectVersionRequest.setVersionName("2.0.0");
ProjectServiceTestIT.projectService.createProjectVersion(ProjectServiceTestIT.project, projectVersionRequest);
List<ProjectVersionView> projectVersionViewsAfterUpdate = ProjectServiceTestIT.blackDuckApiClient.getAllResponses(ProjectServiceTestIT.project.metaVersionsLink());
assertEquals(2, projectVersionViewsAfterUpdate.size());
latestProjectVersionView = ProjectServiceTestIT.projectService.getNewestProjectVersion(ProjectServiceTestIT.project);
assertTrue(latestProjectVersionView.isPresent());
assertEquals("2.0.0", latestProjectVersionView.get().getVersionName());
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testCloning.
@Test
public void testCloning() throws Exception {
// first create a new project with a single version
String projectName = "create" + Instant.now().toString();
String projectVersionName = "1.0.0";
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(projectName, projectVersionName);
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
ProjectServiceTestIT.projectService.createProject(projectRequest);
Optional<ProjectVersionWrapper> projectVersionWrapper = ProjectServiceTestIT.projectService.getProjectVersion(projectName, projectVersionName);
ProjectServiceTestIT.project = projectVersionWrapper.get().getProjectView();
ProjectVersionView projectVersionView = projectVersionWrapper.get().getProjectVersionView();
assertNotNull(ProjectServiceTestIT.project);
assertNotNull(projectVersionView);
HttpUrl projectUrl = ProjectServiceTestIT.project.getHref();
HttpUrl projectVersionUrl = projectVersionView.getHref();
List<ProjectVersionView> projectVersionViews = ProjectServiceTestIT.blackDuckApiClient.getAllResponses(ProjectServiceTestIT.project.metaVersionsLink());
assertEquals(1, projectVersionViews.size());
ProjectServiceTestIT.project.setCloneCategories(Arrays.asList(ProjectCloneCategoriesType.COMPONENT_DATA));
ProjectServiceTestIT.blackDuckApiClient.put(ProjectServiceTestIT.project);
ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
projectVersionRequest.setCloneFromReleaseUrl(projectVersionUrl.string());
projectVersionRequest.setVersionName("1.0.0-clone");
projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
ProjectServiceTestIT.projectService.createProjectVersion(ProjectServiceTestIT.project, projectVersionRequest);
projectVersionViews = ProjectServiceTestIT.blackDuckApiClient.getAllResponses(ProjectServiceTestIT.project.metaVersionsLink());
assertEquals(2, projectVersionViews.size());
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testSetLicenseForProjectVersion.
@Test
public void testSetLicenseForProjectVersion() throws IntegrationException {
String projectName = "InitialName";
deleteProjectIfExists(projectName);
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName(projectName);
projectRequest.setProjectTier(2);
projectRequest.setDescription("Initial Description");
ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
projectVersionRequest.setVersionName("InitialVersion");
projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
ComplexLicenseRequest complexLicenseRequest = new ComplexLicenseRequest();
String licenseName = ".NETZ GPL 2.0 With Exception License";
complexLicenseRequest.setLicense(licenseService.getLicenseUrlByLicenseName(licenseName).get().string());
projectVersionRequest.setLicense(complexLicenseRequest);
projectRequest.setVersionRequest(projectVersionRequest);
ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.createProject(projectRequest);
ProjectVersionView projectVersion = projectVersionWrapper.getProjectVersionView();
Assertions.assertEquals(licenseName, projectVersion.getLicense().getLicenseDisplay());
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-common by blackducksoftware.
the class ProjectService method syncProjectAndVersion.
public ProjectVersionWrapper syncProjectAndVersion(ProjectSyncModel projectSyncModel, boolean performUpdate) throws IntegrationException {
String projectName = projectSyncModel.getName();
Optional<ProjectView> optionalProjectView = getProjectByName(projectName);
if (!optionalProjectView.isPresent()) {
logger.info(String.format("The %s project was not found, so it will be created - if a version was included, it will also be created.", projectName));
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
return createProject(projectRequest);
}
ProjectView projectView = optionalProjectView.get();
if (performUpdate) {
logger.info(String.format("The %s project was found and performUpdate=true, so it will be updated.", projectName));
projectSyncModel.populateProjectView(projectView);
blackDuckApiClient.put(projectView);
projectView = blackDuckApiClient.getResponse(projectView.getHref(), ProjectView.class);
}
ProjectVersionView projectVersionView = null;
if (projectSyncModel.shouldHandleProjectVersion()) {
String projectVersionName = projectSyncModel.getVersionName();
Optional<ProjectVersionView> optionalProjectVersionView = getProjectVersion(projectView, projectVersionName);
if (optionalProjectVersionView.isPresent()) {
projectVersionView = optionalProjectVersionView.get();
if (performUpdate) {
logger.info(String.format("The %s version was found and performUpdate=true, so the version will be updated.", projectVersionName));
projectSyncModel.populateProjectVersionView(projectVersionView);
blackDuckApiClient.put(projectVersionView);
projectVersionView = blackDuckApiClient.getResponse(projectVersionView.getHref(), ProjectVersionView.class);
}
} else {
logger.info(String.format("The %s version was not found, so it will be created under the %s project.", projectVersionName, projectName));
ProjectVersionRequest projectVersionRequest = projectSyncModel.createProjectVersionRequest();
projectVersionView = createProjectVersion(projectView, projectVersionRequest);
}
}
return new ProjectVersionWrapper(projectView, projectVersionView);
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-common by blackducksoftware.
the class ProjectSyncModel method createProjectVersionRequest.
public ProjectVersionRequest createProjectVersionRequest() {
ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
projectVersionRequest.setDistribution(distribution);
projectVersionRequest.setPhase(phase);
projectVersionRequest.setVersionName(versionName);
projectVersionRequest.setReleaseComments(releaseComments);
projectVersionRequest.setCloneFromReleaseUrl(cloneFromReleaseUrl);
projectVersionRequest.setReleasedOn(releasedOn);
projectVersionRequest.setNickname(nickname);
if (fieldSet(ProjectSyncModel.VERSION_LICENSE_URL_FIELD)) {
// A ProjectVersionRequest with a ComplexLicenseRequest that has a null license url triggers a failure
projectVersionRequest.setLicense(createComplexLicenseRequest());
}
return projectVersionRequest;
}
Aggregations