use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class JiraServerExternalConnectionTest method createMessage.
private ProviderMessageHolder createMessage() {
ProviderDetails providerDetails = new ProviderDetails(1L, new LinkableItem("ProviderLabel", "ProviderName"));
SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Test Summary", "Test Description", List.of());
return new ProviderMessageHolder(List.of(), List.of(simpleMessage));
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class AzureBoardsProjectAndVersionIssueFinder method createProjectIssueModel.
private ProjectIssueModel createProjectIssueModel(ProviderDetails providerDetails, LinkableItem project, @Nullable LinkableItem nullableProjectVersion, WorkItemFieldsWrapper workItemFields) {
AzureFieldDefinition<String> projectVersionFieldDef = AzureFieldDefinition.stringField(AzureCustomFieldManager.ALERT_SUB_TOPIC_KEY_FIELD_REFERENCE_NAME);
AzureFieldDefinition<String> componentFieldDef = AzureFieldDefinition.stringField(AzureCustomFieldManager.ALERT_COMPONENT_KEY_FIELD_REFERENCE_NAME);
AzureFieldDefinition<String> subComponentFieldDef = AzureFieldDefinition.stringField(AzureCustomFieldManager.ALERT_SUB_COMPONENT_KEY_FIELD_REFERENCE_NAME);
LinkableItem projectVersion = Optional.ofNullable(nullableProjectVersion).orElse(AzureBoardsWorkItemExtractionUtils.extractLinkableItem(workItemFields, projectVersionFieldDef));
LinkableItem component = AzureBoardsWorkItemExtractionUtils.extractLinkableItem(workItemFields, componentFieldDef);
LinkableItem componentVersion = null;
Optional<String> componentVersionField = workItemFields.getField(subComponentFieldDef);
if (componentVersionField.isPresent()) {
componentVersion = AzureBoardsWorkItemExtractionUtils.extractLinkableItem(componentVersionField.get());
}
IssueBomComponentDetails bomComponent = IssueBomComponentDetails.fromSearchResults(component, componentVersion);
return ProjectIssueModel.bom(providerDetails, project, projectVersion, bomComponent);
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class ProjectVersionNotificationMessageExtractorTest 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);
ProjectVersionNotificationContent projectVersionNotificationContent = createProjectVersionNotificationContent();
NotificationContentWrapper notificationContentWrapper = createNotificationContentWrapper(projectVersionNotificationContent);
ProjectVersionNotificationMessageExtractor extractor = new ProjectVersionNotificationMessageExtractor(providerKey, servicesFactoryCache);
ProviderMessageHolder providerMessageHolder = extractor.extract(notificationContentWrapper, projectVersionNotificationContent);
assertEquals(1, providerMessageHolder.getProjectMessages().size());
assertEquals(0, providerMessageHolder.getSimpleMessages().size());
ProjectMessage projectMessage = providerMessageHolder.getProjectMessages().get(0);
assertEquals(MessageReason.PROJECT_VERSION_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());
assertTrue(projectMessage.getProjectVersion().isPresent());
LinkableItem projectVersion = projectMessage.getProjectVersion().get();
assertEquals(PROJECT_VERSION, projectVersion.getValue());
assertTrue(projectVersion.getUrl().isPresent());
assertEquals(PROJECT_VERSION_URL, projectVersion.getUrl().get());
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class BlackDuckMessageAttributesUtilsTest method testGetLicenseLinkableItemsNullIncluded.
@Test
public void testGetLicenseLinkableItemsNullIncluded() {
String licenseValue = "License Display";
ProjectVersionComponentVersionView projectVersionComponentView = new ProjectVersionComponentVersionView();
List<ProjectVersionComponentVersionLicensesView> projectVersionComponentLicensesViews = new ArrayList<>();
ProjectVersionComponentVersionLicensesView projectVersionComponentLicensesView = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentLicensesView.setLicenseDisplay(licenseValue);
projectVersionComponentLicensesViews.add(projectVersionComponentLicensesView);
projectVersionComponentLicensesViews.add(null);
projectVersionComponentView.setLicenses(projectVersionComponentLicensesViews);
LinkableItem licenseLinkableItem = BlackDuckMessageAttributesUtils.extractLicense(projectVersionComponentView);
assertEquals(licenseValue, licenseLinkableItem.getValue());
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class BlackDuckMessageAttributesUtilsTest method testGetLicenseLinkableItems.
@Test
public void testGetLicenseLinkableItems() {
String licenseValue = "License Display 1";
ProjectVersionComponentVersionView projectVersionComponentView = new ProjectVersionComponentVersionView();
List<ProjectVersionComponentVersionLicensesView> projectVersionComponentLicensesViews = new ArrayList<>();
ProjectVersionComponentVersionLicensesView projectVersionComponentLicensesView1 = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentLicensesView1.setLicenseDisplay(licenseValue);
projectVersionComponentLicensesViews.add(projectVersionComponentLicensesView1);
ProjectVersionComponentVersionLicensesView projectVersionComponentLicensesView2 = new ProjectVersionComponentVersionLicensesView();
projectVersionComponentLicensesView2.setLicenseDisplay("License Display 2");
projectVersionComponentLicensesViews.add(projectVersionComponentLicensesView2);
projectVersionComponentView.setLicenses(projectVersionComponentLicensesViews);
LinkableItem licenseLinkableItem = BlackDuckMessageAttributesUtils.extractLicense(projectVersionComponentView);
assertEquals(licenseValue, licenseLinkableItem.getValue());
}
Aggregations