use of com.synopsys.integration.blackduck.api.manual.component.ProjectNotificationContent in project hub-alert by blackducksoftware.
the class ProjectNotificationMessageExtractorTest method createProjectNotificationContent.
private ProjectNotificationContent createProjectNotificationContent() {
ProjectNotificationContent projectNotificationContent = new ProjectNotificationContent();
projectNotificationContent.setProject(PROJECT_URL);
projectNotificationContent.setProjectName(PROJECT);
projectNotificationContent.setOperationType(OperationType.CREATE);
return projectNotificationContent;
}
use of com.synopsys.integration.blackduck.api.manual.component.ProjectNotificationContent in project hub-alert by blackducksoftware.
the class ProjectNotificationDetailExtractorTest method extractDetailedContentTest.
@Test
public void extractDetailedContentTest() throws IOException {
String jsonContent = TestResourceUtils.readFileToString(NOTIFICATION_JSON_PATH);
ProjectNotificationView projectNotificationView = gson.fromJson(jsonContent, ProjectNotificationView.class);
ProjectNotificationContent projectNotificationContent = projectNotificationView.getContent();
AlertNotificationModel notification = new AlertNotificationModel(0L, 0L, "BlackDuck", "Config 1", null, null, null, null, false);
ProjectNotificationDetailExtractor extractor = new ProjectNotificationDetailExtractor();
List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, projectNotificationView);
assertEquals(1, detailedNotificationContents.size());
DetailedNotificationContent detailedNotificationContent = detailedNotificationContents.get(0);
Optional<String> optionalProjectName = detailedNotificationContent.getProjectName();
assertTrue(optionalProjectName.isPresent(), "Expect project name to be present");
assertEquals(projectNotificationContent.getProjectName(), optionalProjectName.get());
assertTrue(detailedNotificationContent.getPolicyName().isEmpty(), "Expected no policy name to be present");
assertEquals(0, detailedNotificationContent.getVulnerabilitySeverities().size());
}
use of com.synopsys.integration.blackduck.api.manual.component.ProjectNotificationContent in project hub-alert by blackducksoftware.
the class JmsNotificationReceiverTestIT method createAlertNotificationModel.
private AlertNotificationModel createAlertNotificationModel(Long id, boolean processed) {
ProjectNotificationContent projectNotificationContent = new ProjectNotificationContent();
projectNotificationContent.setProject("project");
projectNotificationContent.setProjectName(String.format("projectName-%s", id));
projectNotificationContent.setOperationType(OperationType.CREATE);
ProjectNotificationView projectNotificationView = new ProjectNotificationView();
projectNotificationView.setContent(projectNotificationContent);
projectNotificationView.setType(NotificationType.PROJECT);
String content = gson.toJson(projectNotificationView);
return new AlertNotificationModel(id, blackDuckGlobalConfigId, "provider_blackduck", "DELETED CONFIGURATION", NotificationType.PROJECT.name(), content, DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp(), processed);
}
use of com.synopsys.integration.blackduck.api.manual.component.ProjectNotificationContent in project hub-alert by blackducksoftware.
the class ProjectNotificationMessageExtractorTest method extractTest.
@Test
public void extractTest() throws IntegrationException {
NotificationExtractorBlackDuckServicesFactoryCache servicesFactoryCache = Mockito.mock(NotificationExtractorBlackDuckServicesFactoryCache.class);
BlackDuckServicesFactory blackDuckServicesFactory = Mockito.mock(BlackDuckServicesFactory.class);
BlackDuckHttpClient blackDuckHttpClient = Mockito.mock(BlackDuckHttpClient.class);
Mockito.when(blackDuckHttpClient.getBlackDuckUrl()).thenReturn(new HttpUrl("https://a.blackduck.server.example.com"));
Mockito.when(blackDuckServicesFactory.getBlackDuckHttpClient()).thenReturn(blackDuckHttpClient);
Mockito.when(servicesFactoryCache.retrieveBlackDuckServicesFactory(Mockito.anyLong())).thenReturn(blackDuckServicesFactory);
ProjectNotificationContent projectNotificationContent = createProjectNotificationContent();
NotificationContentWrapper notificationContentWrapper = createNotificationContentWrapper(projectNotificationContent);
ProjectNotificationMessageExtractor extractor = new ProjectNotificationMessageExtractor(providerKey, servicesFactoryCache);
ProviderMessageHolder providerMessageHolder = extractor.extract(notificationContentWrapper, projectNotificationContent);
assertEquals(1, providerMessageHolder.getProjectMessages().size());
assertEquals(0, providerMessageHolder.getSimpleMessages().size());
ProjectMessage projectMessage = providerMessageHolder.getProjectMessages().get(0);
assertEquals(MessageReason.PROJECT_STATUS, projectMessage.getMessageReason());
assertTrue(projectMessage.getOperation().isPresent());
assertEquals(ProjectOperation.CREATE, projectMessage.getOperation().get());
assertTrue(projectMessage.getBomComponents().isEmpty());
assertEquals(PROJECT, projectMessage.getProject().getValue());
assertTrue(projectMessage.getProject().getUrl().isPresent());
assertEquals(PROJECT_URL, projectMessage.getProject().getUrl().get());
assertFalse(projectMessage.getProjectVersion().isPresent());
}
Aggregations