Search in sources :

Example 11 with ProjectVersionModel

use of com.blackducksoftware.integration.hub.notification.ProjectVersionModel 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"));
    }
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) HashMap(java.util.HashMap) ProjectService(com.blackducksoftware.integration.hub.service.ProjectService) NotificationEvent(com.blackducksoftware.integration.hub.notification.NotificationEvent) ProjectVersionModel(com.blackducksoftware.integration.hub.notification.ProjectVersionModel) Date(java.util.Date) NotificationContentItem(com.blackducksoftware.integration.hub.notification.NotificationContentItem) OutputLogger(com.blackducksoftware.integration.hub.alert.OutputLogger) ComponentVersionView(com.blackducksoftware.integration.hub.api.generated.view.ComponentVersionView) Test(org.junit.Test)

Aggregations

ProjectVersionModel (com.blackducksoftware.integration.hub.notification.ProjectVersionModel)11 Date (java.util.Date)11 ComponentVersionView (com.blackducksoftware.integration.hub.api.generated.view.ComponentVersionView)10 Test (org.junit.Test)10 NotificationContentItem (com.blackducksoftware.integration.hub.notification.NotificationContentItem)5 HashMap (java.util.HashMap)5 PolicyRuleView (com.blackducksoftware.integration.hub.api.generated.view.PolicyRuleView)4 NotificationEvent (com.blackducksoftware.integration.hub.notification.NotificationEvent)4 ProjectService (com.blackducksoftware.integration.hub.service.ProjectService)4 MapProcessorCache (com.blackducksoftware.integration.hub.notification.MapProcessorCache)3 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)3 TestLogger (com.blackducksoftware.integration.test.TestLogger)3 ResourceMetadata (com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata)2 AssignedUserView (com.blackducksoftware.integration.hub.api.generated.view.AssignedUserView)2 PolicyViolationContentItem (com.blackducksoftware.integration.hub.notification.PolicyViolationContentItem)2 VulnerabilityContentItem (com.blackducksoftware.integration.hub.notification.VulnerabilityContentItem)2 ComponentService (com.blackducksoftware.integration.hub.service.ComponentService)2 HubService (com.blackducksoftware.integration.hub.service.HubService)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 OutputLogger (com.blackducksoftware.integration.hub.alert.OutputLogger)1