use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testCreateUpdateProject.
@Test
public void testCreateUpdateProject() throws IllegalArgumentException, IntegrationException {
String projectName = "InitialName";
deleteProjectIfExists(projectName);
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName(projectName);
projectRequest.setProjectTier(2);
projectRequest.setDescription("Initial Description");
ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.createProject(projectRequest);
ProjectServiceTestIT.project = projectVersionWrapper.getProjectView();
HttpUrl projectUrl = ProjectServiceTestIT.project.getHref();
assertEquals("InitialName", ProjectServiceTestIT.project.getName());
assertTrue(2 == ProjectServiceTestIT.project.getProjectTier());
assertEquals("Initial Description", ProjectServiceTestIT.project.getDescription());
ProjectServiceTestIT.project.setName("New Name");
ProjectServiceTestIT.project.setProjectTier(4);
ProjectServiceTestIT.project.setDescription("New Description");
ProjectServiceTestIT.blackDuckApiClient.put(ProjectServiceTestIT.project);
ProjectServiceTestIT.project = ProjectServiceTestIT.blackDuckApiClient.getResponse(projectUrl, ProjectView.class);
assertEquals("New Name", ProjectServiceTestIT.project.getName());
assertTrue(4 == ProjectServiceTestIT.project.getProjectTier());
assertEquals("New Description", ProjectServiceTestIT.project.getDescription());
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class ProjectSyncModelTest method testAllFieldsPopulateRequest.
@Test
public void testAllFieldsPopulateRequest() {
Date releasedOn = new Date();
ProjectSyncModel projectSyncModel = new ProjectSyncModel();
projectSyncModel.setProjectTier(1);
projectSyncModel.setNickname("nick");
projectSyncModel.setProjectOwner("owner href");
projectSyncModel.setDescription("desc");
projectSyncModel.setCloneCategories(Arrays.asList(ProjectCloneCategoriesType.COMPONENT_DATA));
projectSyncModel.setReleaseComments("released!");
projectSyncModel.setDistribution(ProjectVersionDistributionType.INTERNAL);
projectSyncModel.setReleasedOn(releasedOn);
projectSyncModel.setProjectLevelAdjustments(true);
projectSyncModel.setCloneFromReleaseUrl("version href");
projectSyncModel.setCustomSignatureEnabled(true);
projectSyncModel.setName("project name");
projectSyncModel.setVersionName("version name");
projectSyncModel.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
assertEquals("project name", projectRequest.getName());
assertEquals("desc", projectRequest.getDescription());
assertEquals("owner href", projectRequest.getProjectOwner());
assertEquals(new Integer(1), projectRequest.getProjectTier());
assertEquals(true, projectRequest.getProjectLevelAdjustments());
assertEquals(Arrays.asList(ProjectCloneCategoriesType.COMPONENT_DATA), projectRequest.getCloneCategories());
assertEquals(true, projectRequest.getCustomSignatureEnabled());
assertEquals("version name", projectRequest.getVersionRequest().getVersionName());
assertEquals("version href", projectRequest.getVersionRequest().getCloneFromReleaseUrl());
assertEquals("nick", projectRequest.getVersionRequest().getNickname());
assertEquals("released!", projectRequest.getVersionRequest().getReleaseComments());
assertEquals(releasedOn, projectRequest.getVersionRequest().getReleasedOn());
assertEquals(ProjectVersionPhaseType.DEVELOPMENT, projectRequest.getVersionRequest().getPhase());
assertEquals(ProjectVersionDistributionType.INTERNAL, projectRequest.getVersionRequest().getDistribution());
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-alert by blackducksoftware.
the class BlackDuckProviderService method findOrCreateBlackDuckProjectAndVersion.
public ProjectVersionWrapper findOrCreateBlackDuckProjectAndVersion(String projectName, String projectVersionName) throws IntegrationException {
setupBlackDuckServicesFactory();
ProjectService projectService = blackDuckServicesFactory.createProjectService();
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName(projectName);
ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
projectVersionRequest.setVersionName(projectVersionName);
projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
projectRequest.setVersionRequest(projectVersionRequest);
Optional<ProjectVersionWrapper> existingProjectVersion = projectService.getProjectVersion(projectRequest.getName(), projectVersionRequest.getVersionName());
if (existingProjectVersion.isPresent()) {
intLogger.info(String.format("Project: %s Version %s already exists", projectName, projectVersionName));
return existingProjectVersion.get();
}
intLogger.info(String.format("Creating project: %s", projectName));
return projectService.createProject(projectRequest);
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-alert by blackducksoftware.
the class BlackDuckProviderService method deleteBlackDuckProjectAndVersion.
public void deleteBlackDuckProjectAndVersion(String projectName, String projectVersionName) throws IntegrationException {
setupBlackDuckServicesFactory();
ProjectService projectService = blackDuckServicesFactory.createProjectService();
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName(projectName);
ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
projectVersionRequest.setVersionName(projectVersionName);
projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
projectRequest.setVersionRequest(projectVersionRequest);
Optional<ProjectVersionWrapper> existingProjectVersion = projectService.getProjectVersion(projectRequest.getName(), projectVersionRequest.getVersionName());
if (existingProjectVersion.isPresent()) {
intLogger.info(String.format("Project: %s Version %s already exists", projectName, projectVersionName));
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
blackDuckApiClient.delete(existingProjectVersion.get().getProjectVersionView());
blackDuckApiClient.delete(existingProjectVersion.get().getProjectView());
intLogger.info(String.format("Deleting project: %s", projectName));
}
}
Aggregations