Search in sources :

Example 1 with ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.

the class ProjectAssignmentServiceTestIT method testGetAssignedUsersFromProjectView.

@Test
public void testGetAssignedUsersFromProjectView() throws IllegalArgumentException, IntegrationException {
    Long timestamp = (new Date()).getTime();
    String testProjectName = "hub-common-it-ProjectAssignmentServiceTest-" + timestamp;
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(testProjectName);
    ProjectVersionWrapper projectVersionWrapper = ProjectAssignmentServiceTestIT.blackDuckServicesFactory.createProjectService().createProject(projectRequest);
    ProjectAssignmentServiceTestIT.project = projectVersionWrapper.getProjectView();
    System.out.println("projectUrl: " + ProjectAssignmentServiceTestIT.project.getHref());
    List<AssignedUserView> assignedUsers = ProjectAssignmentServiceTestIT.blackDuckServicesFactory.createProjectUsersService().getAssignedUsersToProject(ProjectAssignmentServiceTestIT.project);
    assertFalse(assignedUsers.isEmpty());
    assertEquals(1, assignedUsers.size());
    assertEquals("sysadmin", assignedUsers.get(0).getName());
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) AssignedUserView(com.synopsys.integration.blackduck.api.manual.temporary.view.AssignedUserView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 2 with ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest 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 ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project blackduck-common by blackducksoftware.

the class ProjectServiceTestIT method testCreatingProjectWithoutVersion.

@Test
public void testCreatingProjectWithoutVersion() throws Exception {
    String projectName = "create" + Instant.now().toString();
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    ProjectServiceTestIT.projectService.createProject(projectRequest);
    ProjectServiceTestIT.project = ProjectServiceTestIT.projectService.getProjectByName(projectName).get();
    assertEquals(projectName, ProjectServiceTestIT.project.getName());
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) Test(org.junit.jupiter.api.Test)

Example 4 with ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest 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 5 with ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest 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)

Aggregations

ProjectRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest)19 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)15 Test (org.junit.jupiter.api.Test)12 ProjectVersionRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)11 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)8 ProjectService (com.synopsys.integration.blackduck.service.dataservice.ProjectService)6 ProjectSyncModel (com.synopsys.integration.blackduck.service.model.ProjectSyncModel)5 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)4 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)4 HttpUrl (com.synopsys.integration.rest.HttpUrl)3 Date (java.util.Date)3 IntLogger (com.synopsys.integration.log.IntLogger)2 SilentIntLogger (com.synopsys.integration.log.SilentIntLogger)2 ProjectVersionDistributionType (com.synopsys.integration.blackduck.api.generated.enumeration.ProjectVersionDistributionType)1 ComplexLicenseRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ComplexLicenseRequest)1 ProjectVersionPhaseType (com.synopsys.integration.blackduck.api.manual.temporary.enumeration.ProjectVersionPhaseType)1 AssignedUserView (com.synopsys.integration.blackduck.api.manual.temporary.view.AssignedUserView)1 BlackDuckApiException (com.synopsys.integration.blackduck.exception.BlackDuckApiException)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1