use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView in project hub-alert by blackducksoftware.
the class ProviderDataAccessorTest method getProjectVersionsByHrefTest.
@Test
void getProjectVersionsByHrefTest() throws IntegrationException {
ProjectView projectView = createProjectViewWithVersionsLink();
Mockito.when(blackDuckApiClient.getResponse(Mockito.any(HttpUrl.class), Mockito.eq(ProjectView.class))).thenReturn(projectView);
ProjectVersionView projectVersionView = new ProjectVersionView();
String versionName = "versionName";
int totalPages = 1;
projectVersionView.setVersionName(versionName);
BlackDuckPageResponse blackDuckPageResponse = new BlackDuckPageResponse(totalPages, List.of(projectVersionView));
Mockito.when(blackDuckApiClient.getPageResponse(Mockito.any())).thenReturn(blackDuckPageResponse);
BlackDuckProviderDataAccessor blackDuckProviderDataAccessor = new BlackDuckProviderDataAccessor(configurationModelConfigurationAccessor, blackDuckPropertiesFactory);
AlertPagedModel<String> projectVersionNamesByHref = blackDuckProviderDataAccessor.getProjectVersionNamesByHref(1L, HREF_1, 1);
assertNotNull(projectVersionNamesByHref);
assertEquals(totalPages, projectVersionNamesByHref.getTotalPages());
Optional<String> firstFoundProjectVersion = projectVersionNamesByHref.getModels().stream().findFirst();
assertTrue(firstFoundProjectVersion.isPresent());
String foundVersionName = firstFoundProjectVersion.get();
assertEquals(versionName, foundVersionName);
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView in project hub-alert by blackducksoftware.
the class ProviderDataAccessorTest method getProjectVersionsByHrefWithNoConfigTest.
@Test
void getProjectVersionsByHrefWithNoConfigTest() throws IntegrationException {
ProjectView projectView = createProjectViewWithVersionsLink();
Mockito.when(blackDuckApiClient.getResponse(Mockito.any(HttpUrl.class), Mockito.eq(ProjectView.class))).thenReturn(projectView);
ProjectVersionView projectVersionView = new ProjectVersionView();
String versionName = "versionName";
int totalPages = 1;
projectVersionView.setVersionName(versionName);
BlackDuckPageResponse blackDuckPageResponse = new BlackDuckPageResponse(totalPages, List.of(projectVersionView));
Mockito.when(blackDuckApiClient.getPageResponse(Mockito.any())).thenReturn(blackDuckPageResponse);
BlackDuckProviderDataAccessor blackDuckProviderDataAccessor = new BlackDuckProviderDataAccessor(configurationModelConfigurationAccessor, blackDuckPropertiesFactory);
AlertPagedModel<String> projectVersionNamesByHref = blackDuckProviderDataAccessor.getProjectVersionNamesByHref(999L, HREF_1, 1);
assertNotNull(projectVersionNamesByHref);
assertEquals(0, projectVersionNamesByHref.getTotalPages());
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView in project hub-alert by blackducksoftware.
the class BomEditNotificationDetailExtractor method extractDetailedContent.
@Override
public List<DetailedNotificationContent> extractDetailedContent(AlertNotificationModel alertNotificationModel, BomEditNotificationView notificationView) {
BomEditNotificationContent notificationContent = notificationView.getContent();
Optional<ProjectVersionWrapper> optionalProjectAndVersion = retrieveProjectAndVersion(alertNotificationModel.getProviderConfigId(), notificationContent.getProjectVersion());
if (optionalProjectAndVersion.isPresent()) {
ProjectVersionWrapper projectAndVersion = optionalProjectAndVersion.get();
ProjectView project = projectAndVersion.getProjectView();
ProjectVersionView projectVersion = projectAndVersion.getProjectVersionView();
String projectName = project.getName();
BomEditWithProjectNameNotificationContent updatedNotificationContent = new BomEditWithProjectNameNotificationContent(notificationContent, projectName, projectVersion.getVersionName());
DetailedNotificationContent detailedContent = DetailedNotificationContent.project(alertNotificationModel, updatedNotificationContent, projectName, projectVersion.getVersionName());
return List.of(detailedContent);
}
return List.of();
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getProjectVersionNamesByHref.
@Override
public AlertPagedModel<String> getProjectVersionNamesByHref(Long providerConfigId, String projectHref, int pageNumber) {
Optional<ConfigurationModel> providerConfigOptional = configurationModelConfigurationAccessor.getConfigurationById(providerConfigId);
if (providerConfigOptional.isPresent()) {
try {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(providerConfigOptional.get());
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
ProjectView foundProject = blackDuckApiClient.getResponse(new HttpUrl(projectHref), ProjectView.class);
BlackDuckPageDefinition blackDuckPageDefinition = new BlackDuckPageDefinition(BlackDuckRequestBuilder.DEFAULT_LIMIT, pageNumber * BlackDuckRequestBuilder.DEFAULT_LIMIT);
BlackDuckMultipleRequest<ProjectVersionView> projectVersionSpec = new BlackDuckRequestBuilder().commonGet().setBlackDuckPageDefinition(blackDuckPageDefinition).buildBlackDuckRequest(foundProject.metaVersionsLink());
BlackDuckPageResponse<ProjectVersionView> pageResponse = blackDuckApiClient.getPageResponse(projectVersionSpec);
return new AlertPagedModel<>(pageResponse.getTotalCount(), pageNumber, BlackDuckRequestBuilder.DEFAULT_LIMIT, pageResponse.getItems()).transformContent(ProjectVersionView::getVersionName);
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectNotFoundString(providerConfigId, e.getMessage()), e);
}
}
return AlertPagedModel.empty(pageNumber, BlackDuckRequestBuilder.DEFAULT_LIMIT);
}
use of com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView in project hub-alert by blackducksoftware.
the class BlackDuckProviderIssueHandler method retrieveExistingIssue.
private Optional<ProjectVersionIssuesView> retrieveExistingIssue(String projectVersionUrl, String blackDuckIssueId) throws IntegrationException {
HttpUrl projectVersionHttpUrl = new HttpUrl(projectVersionUrl);
ProjectVersionView projectVersion = blackDuckApiClient.getResponse(projectVersionHttpUrl, ProjectVersionView.class);
List<ProjectVersionIssuesView> bomComponentIssues = issueService.getIssuesForProjectVersion(projectVersion);
return bomComponentIssues.stream().filter(issue -> issue.getIssueId().equals(blackDuckIssueId)).findAny();
}
Aggregations