use of com.blackducksoftware.integration.hub.alert.OutputLogger 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"));
}
}
Aggregations