use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class BasicRecipe method createThrowAwayProjects.
public void createThrowAwayProjects(int numberOfProjectsToCreate) throws IntegrationException {
for (int i = 1; i <= numberOfProjectsToCreate; i++) {
String uniqueProjectName = PROJECT_NAME + System.currentTimeMillis();
ProjectSyncModel projectSyncModel = createProjectSyncModel(uniqueProjectName, PROJECT_VERSION_NAME);
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
projectService.createProject(projectRequest);
}
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class ComprehensiveCookbookTestIT method createProjectVersion.
@Test
public void createProjectVersion() throws Exception {
String testProjectName = intHttpClientTestHelper.getProperty("TEST_CREATE_PROJECT");
ProjectService projectService = blackDuckServicesFactory.createProjectService();
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
IntLogger logger = blackDuckServicesFactory.getLogger();
// delete the project, if it exists
intHttpClientTestHelper.deleteIfProjectExists(logger, projectService, blackDuckApiClient, testProjectName);
// get the count of all projects now
int projectCount = blackDuckApiClient.getAllResponses(apiDiscovery.metaProjectsLink()).size();
// create the project
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName(testProjectName);
ProjectVersionWrapper projectVersionWrapper = projectService.createProject(projectRequest);
ProjectView projectItem = projectVersionWrapper.getProjectView();
Optional<ProjectView> projectItemFromName = projectService.getProjectByName(testProjectName);
// should return the same project
assertTrue(projectItemFromName.isPresent());
assertEquals(projectItem.toString(), projectItemFromName.get().toString());
int projectCountAfterCreate = blackDuckApiClient.getAllResponses(apiDiscovery.metaProjectsLink()).size();
assertTrue(projectCountAfterCreate > projectCount);
int projectVersionCount = blackDuckApiClient.getAllResponses(projectItem.metaVersionsLink()).size();
ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
projectVersionRequest.setDistribution(ProjectVersionDistributionType.INTERNAL);
projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest.setVersionName("RestConnectionTest");
ProjectVersionView projectVersionItem = projectService.createProjectVersion(projectItem, projectVersionRequest);
Optional<ProjectVersionView> projectVersionItemFromName = projectService.getProjectVersion(projectItem, "RestConnectionTest");
// should return the same project version
assertTrue(projectVersionItemFromName.isPresent());
assertEquals(projectVersionItem.toString(), projectVersionItemFromName.get().toString());
assertTrue(blackDuckApiClient.getAllResponses(projectItem.metaVersionsLink()).size() > projectVersionCount);
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class ComprehensiveCookbookTestIT method createProjectVersionSingleCall.
@Test
public void createProjectVersionSingleCall() throws Exception {
String testProjectName = intHttpClientTestHelper.getProperty("TEST_CREATE_PROJECT");
ProjectService projectService = blackDuckServicesFactory.createProjectService();
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
IntLogger logger = blackDuckServicesFactory.getLogger();
// delete the project, if it exists
intHttpClientTestHelper.deleteIfProjectExists(logger, projectService, blackDuckApiClient, testProjectName);
// get the count of all projects now
int projectCount = blackDuckApiClient.getAllResponses(apiDiscovery.metaProjectsLink()).size();
String versionName = "RestConnectionTest";
ProjectVersionDistributionType distribution = ProjectVersionDistributionType.INTERNAL;
ProjectVersionPhaseType phase = ProjectVersionPhaseType.DEVELOPMENT;
ProjectSyncModel projectSyncModel = new ProjectSyncModel(testProjectName, versionName);
projectSyncModel.setPhase(phase);
projectSyncModel.setDistribution(distribution);
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
// create the project
ProjectVersionWrapper projectVersionWrapper = projectService.createProject(projectRequest);
ProjectView projectItem = projectVersionWrapper.getProjectView();
Optional<ProjectView> projectItemFromName = projectService.getProjectByName(testProjectName);
// should return the same project
assertTrue(projectItemFromName.isPresent());
assertEquals(projectItem.toString(), projectItemFromName.get().toString());
int projectCountAfterCreate = blackDuckApiClient.getAllResponses(apiDiscovery.metaProjectsLink()).size();
assertTrue(projectCountAfterCreate > projectCount);
Optional<ProjectVersionView> projectVersionItem = projectService.getProjectVersion(projectItem, versionName);
assertTrue(projectVersionItem.isPresent());
assertEquals(versionName, projectVersionItem.get().getVersionName());
// should return the same project version
assertEquals(projectVersionWrapper.getProjectVersionView().toString(), projectVersionItem.get().toString());
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testCreateDeleteWithNickname.
@Test
public void testCreateDeleteWithNickname() throws IllegalArgumentException, IntegrationException {
Long timestamp = (new Date()).getTime();
String testProjectName = "hub-common-it-ProjectServiceTest-" + timestamp;
String testProjectVersion1Name = "1";
String testProjectVersion2Name = "2";
String testProjectVersion3Name = "3";
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName(testProjectName);
ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.createProject(projectRequest);
ProjectServiceTestIT.project = projectVersionWrapper.getProjectView();
HttpUrl projectUrl = ProjectServiceTestIT.project.getHref();
System.out.println("projectUrl: " + projectUrl);
ProjectVersionRequest projectVersionRequest1 = new ProjectVersionRequest();
projectVersionRequest1.setDistribution(ProjectVersionDistributionType.INTERNAL);
projectVersionRequest1.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest1.setVersionName(testProjectVersion1Name);
ProjectVersionRequest projectVersionRequest2 = new ProjectVersionRequest();
projectVersionRequest2.setDistribution(ProjectVersionDistributionType.INTERNAL);
projectVersionRequest2.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest2.setVersionName(testProjectVersion2Name);
ProjectVersionRequest projectVersionRequest3 = new ProjectVersionRequest();
projectVersionRequest3.setDistribution(ProjectVersionDistributionType.INTERNAL);
projectVersionRequest3.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
projectVersionRequest3.setVersionName(testProjectVersion3Name);
ProjectServiceTestIT.projectService.createProjectVersion(ProjectServiceTestIT.project, projectVersionRequest1);
ProjectServiceTestIT.projectService.createProjectVersion(ProjectServiceTestIT.project, projectVersionRequest2);
ProjectServiceTestIT.projectService.createProjectVersion(ProjectServiceTestIT.project, projectVersionRequest3);
Optional<ProjectVersionView> projectVersion1 = ProjectServiceTestIT.projectService.getProjectVersion(ProjectServiceTestIT.project, testProjectVersion1Name);
assertEquals(testProjectVersion1Name, projectVersion1.get().getVersionName());
Optional<ProjectVersionView> projectVersion2 = ProjectServiceTestIT.projectService.getProjectVersion(ProjectServiceTestIT.project, testProjectVersion2Name);
assertEquals(testProjectVersion2Name, projectVersion2.get().getVersionName());
Optional<ProjectVersionView> projectVersion3 = ProjectServiceTestIT.projectService.getProjectVersion(ProjectServiceTestIT.project, testProjectVersion3Name);
assertEquals(testProjectVersion3Name, projectVersion3.get().getVersionName());
ProjectServiceTestIT.blackDuckApiClient.delete(ProjectServiceTestIT.project);
ProjectServiceTestIT.project = null;
try {
ProjectServiceTestIT.blackDuckApiClient.getResponse(projectUrl, ProjectView.class);
fail("This project should have been deleted");
} catch (Exception e) {
assertTrue(e instanceof BlackDuckApiException);
assertTrue(RestConstants.NOT_FOUND_404 == ((BlackDuckApiException) e).getOriginalIntegrationRestException().getHttpStatusCode());
}
}
use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testCreateUpdateProjectVersion.
@Test
public void testCreateUpdateProjectVersion() throws IllegalArgumentException, 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("Initial VersionName");
projectVersionRequest.setPhase(ProjectVersionPhaseType.PLANNING);
projectVersionRequest.setDistribution(ProjectVersionDistributionType.EXTERNAL);
projectRequest.setVersionRequest(projectVersionRequest);
ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.createProject(projectRequest);
ProjectServiceTestIT.project = projectVersionWrapper.getProjectView();
ProjectVersionView projectVersionView = projectVersionWrapper.getProjectVersionView();
assertEquals("Initial VersionName", projectVersionView.getVersionName());
assertEquals(ProjectVersionPhaseType.PLANNING, projectVersionView.getPhase());
assertEquals(ProjectVersionDistributionType.EXTERNAL, projectVersionView.getDistribution());
projectVersionView.setVersionName("New VersionName");
projectVersionView.setPhase(ProjectVersionPhaseType.DEPRECATED);
projectVersionView.setDistribution(ProjectVersionDistributionType.INTERNAL);
ProjectServiceTestIT.blackDuckApiClient.put(projectVersionView);
projectVersionView = ProjectServiceTestIT.blackDuckApiClient.getResponse(projectVersionView.getHref(), ProjectVersionView.class);
assertEquals("New VersionName", projectVersionView.getVersionName());
assertEquals(ProjectVersionPhaseType.DEPRECATED, projectVersionView.getPhase());
assertEquals(ProjectVersionDistributionType.INTERNAL, projectVersionView.getDistribution());
}
Aggregations