use of com.synopsys.integration.blackduck.api.generated.view.IssueView 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"));
}
Aggregations