Search in sources :

Example 16 with ProjectRequest

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

the class ProjectServiceTestIT method testCreateUpdateProject.

@Test
public void testCreateUpdateProject() throws IllegalArgumentException, IntegrationException {
    String projectName = "InitialName";
    deleteProjectIfExists(projectName);
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    projectRequest.setProjectTier(2);
    projectRequest.setDescription("Initial Description");
    ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.createProject(projectRequest);
    ProjectServiceTestIT.project = projectVersionWrapper.getProjectView();
    HttpUrl projectUrl = ProjectServiceTestIT.project.getHref();
    assertEquals("InitialName", ProjectServiceTestIT.project.getName());
    assertTrue(2 == ProjectServiceTestIT.project.getProjectTier());
    assertEquals("Initial Description", ProjectServiceTestIT.project.getDescription());
    ProjectServiceTestIT.project.setName("New Name");
    ProjectServiceTestIT.project.setProjectTier(4);
    ProjectServiceTestIT.project.setDescription("New Description");
    ProjectServiceTestIT.blackDuckApiClient.put(ProjectServiceTestIT.project);
    ProjectServiceTestIT.project = ProjectServiceTestIT.blackDuckApiClient.getResponse(projectUrl, ProjectView.class);
    assertEquals("New Name", ProjectServiceTestIT.project.getName());
    assertTrue(4 == ProjectServiceTestIT.project.getProjectTier());
    assertEquals("New Description", ProjectServiceTestIT.project.getDescription());
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) HttpUrl(com.synopsys.integration.rest.HttpUrl) Test(org.junit.jupiter.api.Test)

Example 17 with ProjectRequest

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

the class ProjectSyncModelTest method testAllFieldsPopulateRequest.

@Test
public void testAllFieldsPopulateRequest() {
    Date releasedOn = new Date();
    ProjectSyncModel projectSyncModel = new ProjectSyncModel();
    projectSyncModel.setProjectTier(1);
    projectSyncModel.setNickname("nick");
    projectSyncModel.setProjectOwner("owner href");
    projectSyncModel.setDescription("desc");
    projectSyncModel.setCloneCategories(Arrays.asList(ProjectCloneCategoriesType.COMPONENT_DATA));
    projectSyncModel.setReleaseComments("released!");
    projectSyncModel.setDistribution(ProjectVersionDistributionType.INTERNAL);
    projectSyncModel.setReleasedOn(releasedOn);
    projectSyncModel.setProjectLevelAdjustments(true);
    projectSyncModel.setCloneFromReleaseUrl("version href");
    projectSyncModel.setCustomSignatureEnabled(true);
    projectSyncModel.setName("project name");
    projectSyncModel.setVersionName("version name");
    projectSyncModel.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
    ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
    assertEquals("project name", projectRequest.getName());
    assertEquals("desc", projectRequest.getDescription());
    assertEquals("owner href", projectRequest.getProjectOwner());
    assertEquals(new Integer(1), projectRequest.getProjectTier());
    assertEquals(true, projectRequest.getProjectLevelAdjustments());
    assertEquals(Arrays.asList(ProjectCloneCategoriesType.COMPONENT_DATA), projectRequest.getCloneCategories());
    assertEquals(true, projectRequest.getCustomSignatureEnabled());
    assertEquals("version name", projectRequest.getVersionRequest().getVersionName());
    assertEquals("version href", projectRequest.getVersionRequest().getCloneFromReleaseUrl());
    assertEquals("nick", projectRequest.getVersionRequest().getNickname());
    assertEquals("released!", projectRequest.getVersionRequest().getReleaseComments());
    assertEquals(releasedOn, projectRequest.getVersionRequest().getReleasedOn());
    assertEquals(ProjectVersionPhaseType.DEVELOPMENT, projectRequest.getVersionRequest().getPhase());
    assertEquals(ProjectVersionDistributionType.INTERNAL, projectRequest.getVersionRequest().getDistribution());
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 18 with ProjectRequest

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

the class BlackDuckProviderService method findOrCreateBlackDuckProjectAndVersion.

public ProjectVersionWrapper findOrCreateBlackDuckProjectAndVersion(String projectName, String projectVersionName) throws IntegrationException {
    setupBlackDuckServicesFactory();
    ProjectService projectService = blackDuckServicesFactory.createProjectService();
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
    projectVersionRequest.setVersionName(projectVersionName);
    projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
    projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
    projectRequest.setVersionRequest(projectVersionRequest);
    Optional<ProjectVersionWrapper> existingProjectVersion = projectService.getProjectVersion(projectRequest.getName(), projectVersionRequest.getVersionName());
    if (existingProjectVersion.isPresent()) {
        intLogger.info(String.format("Project: %s Version %s already exists", projectName, projectVersionName));
        return existingProjectVersion.get();
    }
    intLogger.info(String.format("Creating project: %s", projectName));
    return projectService.createProject(projectRequest);
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)

Example 19 with ProjectRequest

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

the class BlackDuckProviderService method deleteBlackDuckProjectAndVersion.

public void deleteBlackDuckProjectAndVersion(String projectName, String projectVersionName) throws IntegrationException {
    setupBlackDuckServicesFactory();
    ProjectService projectService = blackDuckServicesFactory.createProjectService();
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
    projectVersionRequest.setVersionName(projectVersionName);
    projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
    projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
    projectRequest.setVersionRequest(projectVersionRequest);
    Optional<ProjectVersionWrapper> existingProjectVersion = projectService.getProjectVersion(projectRequest.getName(), projectVersionRequest.getVersionName());
    if (existingProjectVersion.isPresent()) {
        intLogger.info(String.format("Project: %s Version %s already exists", projectName, projectVersionName));
        BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
        blackDuckApiClient.delete(existingProjectVersion.get().getProjectVersionView());
        blackDuckApiClient.delete(existingProjectVersion.get().getProjectView());
        intLogger.info(String.format("Deleting project: %s", projectName));
    }
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)

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