use of com.synopsys.integration.blackduck.service.model.ProjectSyncModel in project blackduck-common by blackducksoftware.
the class IssueServiceTestIT method addingAndRetrievingIssues.
@Test
public void addingAndRetrievingIssues() throws IntegrationException {
// create the project/version
String projectName = "issues_test";
String versionName = "1.0.0";
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(projectName, versionName);
ProjectVersionWrapper projectVersionWrapper = projectService.syncProjectAndVersion(projectSyncModel);
// delete it when we're done
project = projectVersionWrapper.getProjectView();
// add some components to the BOM
ExternalId blackDuckCommon = externalIdFactory.createMavenExternalId("com.synopsys.integration", "blackduck-common", "50.0.0");
ExternalId apacheFileUpload = externalIdFactory.createMavenExternalId("commons-fileupload", "commons-fileupload");
projectBomService.addComponentToProjectVersion(blackDuckCommon, projectVersionWrapper.getProjectVersionView());
projectBomService.addComponentToProjectVersion(apacheFileUpload, projectVersionWrapper.getProjectVersionView());
List<ProjectVersionComponentVersionView> componentsForProjectVersion = projectBomService.getComponentsForProjectVersion(projectVersionWrapper.getProjectVersionView());
assertEquals(2, componentsForProjectVersion.size());
// check existing issues
List<ProjectVersionIssuesView> issuesForProjectVersion = issueService.getIssuesForProjectVersion(projectVersionWrapper.getProjectVersionView());
assertEquals(0, issuesForProjectVersion.size());
ProjectVersionComponentVersionView blackduckCommonComponent = componentsForProjectVersion.stream().filter(component -> component.getComponentName().equalsIgnoreCase("blackduck-common")).findAny().get();
ProjectVersionComponentVersionView fileUploadComponent = componentsForProjectVersion.stream().filter(component -> !component.getComponentName().equalsIgnoreCase("blackduck-common")).findAny().get();
// add some issues
IssueRequest blackduckCommonIssue = createIssueRequest("bd-common-1", "bd desc 1");
IssueRequest fileUploadIssue = createIssueRequest("apache-1", "apache desc 1");
issueService.createIssueForComponent(blackduckCommonComponent, blackduckCommonIssue);
issueService.createIssueForComponent(fileUploadComponent, fileUploadIssue);
// check issues added and found
issuesForProjectVersion = issueService.getIssuesForProjectVersion(projectVersionWrapper.getProjectVersionView());
assertEquals(2, issuesForProjectVersion.size());
Set<String> descriptions = convert(issuesForProjectVersion).stream().map(IssueView::getIssueDescription).collect(Collectors.toSet());
assertTrue(descriptions.contains("bd desc 1"));
assertTrue(descriptions.contains("apache desc 1"));
Optional<IssueView> issueByKey = issueService.getIssueByKey(projectVersionWrapper.getProjectVersionView(), "bd-common-1");
assertTrue(issueByKey.get().getIssueDescription().equals("bd desc 1"));
// update issue
issueByKey.get().setIssueDescription("bd desc 2");
issueService.updateIssue(issueByKey.get());
Optional<IssueView> updatedIssue = issueService.getIssueByKey(projectVersionWrapper.getProjectVersionView(), "bd-common-1");
assertTrue(updatedIssue.get().getIssueDescription().equals("bd desc 2"));
}
use of com.synopsys.integration.blackduck.service.model.ProjectSyncModel 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.service.model.ProjectSyncModel in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testJapaneseCharacterSupport.
@Test
public void testJapaneseCharacterSupport() throws IntegrationException {
deleteProjectIfExists(JAPANESE_PROJECT_NAME);
int initialProjectCount = ProjectServiceTestIT.projectService.getAllProjects().size();
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(JAPANESE_PROJECT_NAME, JAPANESE_VERSION_NAME);
ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
ProjectServiceTestIT.projectService.createProject(projectRequest);
Optional<ProjectVersionWrapper> optionalProjectVersionWrapper = ProjectServiceTestIT.projectService.getProjectVersion(JAPANESE_PROJECT_NAME, JAPANESE_VERSION_NAME);
assertTrue(optionalProjectVersionWrapper.isPresent());
int currentProjectCount = ProjectServiceTestIT.projectService.getAllProjects().size();
assertEquals(initialProjectCount + 1, currentProjectCount);
ProjectServiceTestIT.blackDuckApiClient.delete(optionalProjectVersionWrapper.get().getProjectView());
currentProjectCount = ProjectServiceTestIT.projectService.getAllProjects().size();
assertEquals(initialProjectCount, currentProjectCount);
}
use of com.synopsys.integration.blackduck.service.model.ProjectSyncModel 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.service.model.ProjectSyncModel in project blackduck-common by blackducksoftware.
the class ProjectServiceTestIT method testProjectSyncModelUpdatesSetFieldsOnly.
@Test
public void testProjectSyncModelUpdatesSetFieldsOnly() throws IntegrationException {
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults("testSync", "testSyncVersion");
projectSyncModel.setProjectTier(2);
projectSyncModel.setDescription("original");
projectSyncModel.setNickname("panda bear");
ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.syncProjectAndVersion(projectSyncModel, true);
ProjectServiceTestIT.project = projectVersionWrapper.getProjectView();
ProjectSyncModel updateProjectSyncModel = new ProjectSyncModel("testSync", "testSyncVersion");
ProjectVersionWrapper firstUpdate = ProjectServiceTestIT.projectService.syncProjectAndVersion(updateProjectSyncModel, true);
assertEquals(new Integer(2), firstUpdate.getProjectView().getProjectTier());
assertEquals("original", firstUpdate.getProjectView().getDescription());
assertEquals("panda bear", firstUpdate.getProjectVersionView().getNickname());
assertEquals(ProjectVersionPhaseType.DEVELOPMENT, firstUpdate.getProjectVersionView().getPhase());
ProjectSyncModel update2ProjectSyncModel = new ProjectSyncModel("testSync", "testSyncVersion");
update2ProjectSyncModel.setProjectTier(3);
update2ProjectSyncModel.setNickname("honey badger");
ProjectVersionWrapper secondUpdate = ProjectServiceTestIT.projectService.syncProjectAndVersion(update2ProjectSyncModel, true);
assertEquals(new Integer(3), secondUpdate.getProjectView().getProjectTier());
assertEquals("original", secondUpdate.getProjectView().getDescription());
assertEquals("honey badger", secondUpdate.getProjectVersionView().getNickname());
assertEquals(ProjectVersionPhaseType.DEVELOPMENT, secondUpdate.getProjectVersionView().getPhase());
}
Aggregations