Search in sources :

Example 1 with IssueView

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"));
}
Also used : ProjectVersionIssuesView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView) IssueRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest) ProjectSyncModel(com.synopsys.integration.blackduck.service.model.ProjectSyncModel) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) IssueView(com.synopsys.integration.blackduck.api.generated.view.IssueView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView) Test(org.junit.jupiter.api.Test)

Aggregations

ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 IssueView (com.synopsys.integration.blackduck.api.generated.view.IssueView)1 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)1 ProjectVersionIssuesView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionIssuesView)1 IssueRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.IssueRequest)1 ProjectSyncModel (com.synopsys.integration.blackduck.service.model.ProjectSyncModel)1 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 Test (org.junit.jupiter.api.Test)1