use of com.blackducksoftware.integration.hub.service.ProjectService in project hub-alert by blackducksoftware.
the class UserNotificationCacheTest method testAddUserInformationException.
@Test
public void testAddUserInformationException() throws Exception {
try (OutputLogger outputLogger = new OutputLogger()) {
final ProjectService mockedProjectService = Mockito.mock(ProjectService.class);
final UserNotificationCache userNotificationCache = new UserNotificationCache(mockedProjectService);
Mockito.doThrow(new IntegrationException()).when(mockedProjectService).getAssignedUsersToProject(Mockito.anyString());
final Date createdAt = new Date();
final ProjectVersionModel projectVersionModel = new ProjectVersionModel();
projectVersionModel.setProjectLink("New project link");
final String componentName = "notification test";
final ComponentVersionView componentVersionView = new ComponentVersionView();
final String componentVersionUrl = "sss";
final String componentIssueUrl = "ddd";
final Map<String, Object> dataSet = new HashMap<>();
dataSet.put(NotificationEvent.DATA_SET_KEY_NOTIFICATION_CONTENT, new NotificationContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentVersionUrl, componentIssueUrl));
final NotificationEvent notificationEvent = new NotificationEvent("key", NotificationCategoryEnum.HIGH_VULNERABILITY, dataSet);
final List<NotificationEvent> notificationEvents = Arrays.asList(notificationEvent);
Collection<NotificationEvent> emptyEventList = Arrays.asList();
assertEquals(0, emptyEventList.size());
emptyEventList = userNotificationCache.addUserInformation(notificationEvents);
assertEquals(0, emptyEventList.size());
assertTrue(outputLogger.isLineContainingText("Error getting the users for project"));
}
}
use of com.blackducksoftware.integration.hub.service.ProjectService in project hub-alert by blackducksoftware.
the class NotificationItemProcessor method init.
public void init(final GlobalProperties globalProperties, final IntLogger intLogger) {
HubServicesFactory hubServicesFactory;
try {
hubServicesFactory = globalProperties.createHubServicesFactory(intLogger);
final ProjectService projectService = hubServicesFactory.createProjectService();
final MapProcessorCache policyCache = new UserNotificationCache(projectService);
final VulnerabilityCache vulnerabilityCache = new VulnerabilityCache(projectService, hubServicesFactory);
getCacheList().add(policyCache);
getCacheList().add(vulnerabilityCache);
getProcessorMap().put(PolicyViolationContentItem.class, new PolicyViolationProcessor(policyCache, intLogger));
getProcessorMap().put(PolicyViolationClearedContentItem.class, new PolicyViolationClearedProcessor(policyCache, intLogger));
getProcessorMap().put(PolicyOverrideContentItem.class, new PolicyOverrideProcessor(policyCache, intLogger));
getProcessorMap().put(VulnerabilityContentItem.class, new VulnerabilityProcessor(vulnerabilityCache, intLogger));
} catch (final IntegrationException ex) {
intLogger.error("Error building the notification processor", ex);
}
}
Aggregations