use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTest method handleEventTest.
@Test
void handleEventTest() throws IOException {
AlertNotificationModel alertNotificationModel = createAlertNotificationModel(1L, false);
List<AlertNotificationModel> alertNotificationModels = List.of(alertNotificationModel);
NotificationAccessor notificationAccessor = new MockNotificationAccessor(alertNotificationModels);
NotificationProcessor notificationProcessor = mockNotificationProcessor(notificationAccessor);
EventManager eventManager = mockEventManager();
NotificationReceivedEventHandler eventHandler = new NotificationReceivedEventHandler(notificationAccessor, notificationProcessor, eventManager);
try {
eventHandler.handle(new NotificationReceivedEvent());
} catch (RuntimeException e) {
fail("Unable to handle event", e);
}
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class JobNotificationMapperTestIT method createVulnerabilityNotificationWrappers.
private List<DetailedNotificationContent> createVulnerabilityNotificationWrappers(List<String> vulnerabilitySeverities, String projectName, String projectVersionName) {
AlertNotificationModel alertNotificationModel = createAlertNotificationModel(NotificationType.VULNERABILITY);
DetailedNotificationContent test_project = DetailedNotificationContent.vulnerability(alertNotificationModel, createVulnerabilityUniqueProjectNotificationContent(projectName), projectName, projectVersionName, vulnerabilitySeverities);
return List.of(test_project);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel 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.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class JmsNotificationReceiverTestIT method init.
@BeforeEach
public void init() {
properties = new TestProperties();
ConfigurationFieldModel providerConfigEnabled = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED);
providerConfigEnabled.setFieldValue("TRUE");
ConfigurationFieldModel providerConfigName = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
providerConfigName.setFieldValue("blackduck-config");
ConfigurationFieldModel blackduckUrl = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
blackduckUrl.setFieldValue("https://www.synopsys.com");
ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackduckApiKey.setFieldValue("someApiKey");
ConfigurationFieldModel blackduckTimeout = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
blackduckTimeout.setFieldValue(String.valueOf(BlackDuckProperties.DEFAULT_TIMEOUT));
ConfigurationModel blackduckConfigurationModel = defaultConfigurationAccessor.createConfiguration(blackDuckProviderKey, ConfigContextEnum.GLOBAL, List.of(providerConfigEnabled, providerConfigName, blackduckUrl, blackduckApiKey, blackduckTimeout));
blackDuckGlobalConfigId = blackduckConfigurationModel.getConfigurationId();
List<AlertNotificationModel> notificationContent = new ArrayList<>();
for (Long i = 1L; i <= 1000; i++) {
notificationContent.add(createAlertNotificationModel(i, false));
}
savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
SlackJobDetailsModel slackJobDetailsModel = createSlackJobDetailsModel();
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobRequestModel("jobName1", slackJobDetailsModel);
distributionJobModel = staticJobAccessor.createJob(distributionJobRequestModel);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method testHandleEventProcessedNotificationsWithPages.
@Test
void testHandleEventProcessedNotificationsWithPages() {
EventManager eventManagerSpy = Mockito.spy(eventManager);
int totalNotifications = 200;
List<AlertNotificationModel> notificationContent = new ArrayList<>();
for (int index = 0; index < totalNotifications; index++) {
notificationContent.add(createAlertNotificationModel(false));
}
List<AlertNotificationModel> savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
assertNotNull(savedModels);
NotificationProcessor notificationProcessor = createNotificationProcessor();
NotificationReceivedEventHandler notificationReceivedEventHandler = new NotificationReceivedEventHandler(defaultNotificationAccessor, notificationProcessor, eventManagerSpy);
notificationReceivedEventHandler.handle(new NotificationReceivedEvent());
Mockito.verify(eventManagerSpy, Mockito.atLeastOnce()).sendEvent(Mockito.any());
assertEquals(100, defaultNotificationAccessor.getFirstPageOfNotificationsNotProcessed(100).getModels().size());
}
Aggregations