use of com.synopsys.integration.blackduck.service.model.ProjectSyncModel in project blackduck-common by blackducksoftware.
the class CreateDetailedProjectRecipeTest method testCreatingAProject.
@Test
public void testCreatingAProject() throws IntegrationException {
/*
* let's post the project/version in Black Duck
*/
String uniqueProjectName = PROJECT_NAME + System.currentTimeMillis();
ProjectSyncModel projectSyncModel = createProjectSyncModel(uniqueProjectName, PROJECT_VERSION_NAME);
ProjectService projectService = blackDuckServicesFactory.createProjectService();
ProjectVersionWrapper projectVersionWrapper = projectService.createProject(projectSyncModel.createProjectRequest());
HttpUrl projectUrl = projectVersionWrapper.getProjectView().getHref();
/*
* using the url of the created project, we can now verify that the
* fields are set correctly with the BlackDuckService, a general purpose API
* wrapper to handle common GET requests and their response payloads
*/
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
projectView = blackDuckApiClient.getResponse(projectUrl, ProjectView.class);
ProjectVersionView projectVersionView = blackDuckApiClient.getResponse(projectView.metaCanonicalVersionLink());
Assertions.assertEquals(uniqueProjectName, projectView.getName());
Assertions.assertEquals("A sample testing project to demonstrate blackduck-common capabilities.", projectView.getDescription());
Assertions.assertEquals(PROJECT_VERSION_NAME, projectVersionView.getVersionName());
Assertions.assertEquals(ProjectVersionPhaseType.DEVELOPMENT, projectVersionView.getPhase());
Assertions.assertEquals(ProjectVersionDistributionType.OPENSOURCE, projectVersionView.getDistribution());
}
use of com.synopsys.integration.blackduck.service.model.ProjectSyncModel in project blackduck-common by blackducksoftware.
the class ProjectErrorsRecipeTest method testTryingToCreateAProjectThatAlreadyExists.
@Test
public void testTryingToCreateAProjectThatAlreadyExists() throws IntegrationException {
/*
* First, create a project with a unique name
*/
ProjectSyncModel projectSyncModel = createProjectSyncModel(uniqueName, PROJECT_VERSION_NAME);
ProjectVersionWrapper projectVersionWrapper = projectService.createProject(projectSyncModel.createProjectRequest());
projectView = projectVersionWrapper.getProjectView();
/*
* Try to create a project with the same name, which should throw an Exception
*/
try {
projectService.createProject(projectSyncModel.createProjectRequest());
Assertions.fail("Should have thrown an IntegrationRestException");
} catch (Exception e) {
Assertions.assertTrue(e instanceof BlackDuckApiException);
// since the project already existed, a 412 Precondition Failed http error response should occur
Assertions.assertEquals(412, ((BlackDuckApiException) e).getOriginalIntegrationRestException().getHttpStatusCode());
}
}
use of com.synopsys.integration.blackduck.service.model.ProjectSyncModel in project blackduck-common by blackducksoftware.
the class ProjectMappingServiceTest method setUp.
@BeforeEach
void setUp() throws IntegrationException {
IntHttpClientTestHelper intHttpClientTestHelper = new IntHttpClientTestHelper();
blackDuckServicesFactory = intHttpClientTestHelper.createBlackDuckServicesFactory();
projectMappingService = blackDuckServicesFactory.createProjectMappingService();
ProjectService projectService = blackDuckServicesFactory.createProjectService();
String testProjectName = intHttpClientTestHelper.getProperty("TEST_PROJECT");
String testProjectVersion = intHttpClientTestHelper.getProperty("TEST_VERSION");
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(testProjectName, testProjectVersion);
ProjectVersionWrapper projectVersionWrapper = projectService.syncProjectAndVersion(projectSyncModel);
projectView = projectVersionWrapper.getProjectView();
}
Aggregations