Search in sources :

Example 1 with ProjectSyncModel

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"));
}
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)

Example 2 with ProjectSyncModel

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());
}
Also used : ProjectSyncModel(com.synopsys.integration.blackduck.service.model.ProjectSyncModel) ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest) Test(org.junit.jupiter.api.Test)

Example 3 with ProjectSyncModel

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);
}
Also used : ProjectSyncModel(com.synopsys.integration.blackduck.service.model.ProjectSyncModel) ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) Test(org.junit.jupiter.api.Test)

Example 4 with ProjectSyncModel

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());
}
Also used : ProjectSyncModel(com.synopsys.integration.blackduck.service.model.ProjectSyncModel) ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) HttpUrl(com.synopsys.integration.rest.HttpUrl) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest) Test(org.junit.jupiter.api.Test)

Example 5 with ProjectSyncModel

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());
}
Also used : ProjectSyncModel(com.synopsys.integration.blackduck.service.model.ProjectSyncModel) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectSyncModel (com.synopsys.integration.blackduck.service.model.ProjectSyncModel)23 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)15 Test (org.junit.jupiter.api.Test)13 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)6 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)6 ProjectService (com.synopsys.integration.blackduck.service.dataservice.ProjectService)6 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)5 ProjectRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest)5 IntLogger (com.synopsys.integration.log.IntLogger)5 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)4 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)4 HttpUrl (com.synopsys.integration.rest.HttpUrl)4 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)3 ProjectBomService (com.synopsys.integration.blackduck.service.dataservice.ProjectBomService)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)2 CodeLocationView (com.synopsys.integration.blackduck.api.generated.view.CodeLocationView)2 PolicyRuleView (com.synopsys.integration.blackduck.api.generated.view.PolicyRuleView)2 ProjectVersionRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)2 BlackDuckApiException (com.synopsys.integration.blackduck.exception.BlackDuckApiException)2