Search in sources :

Example 6 with MockNotificationEntity

use of com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity in project hub-alert by blackducksoftware.

the class RealTimeListenerTest method testReceiveMessage.

@Test
public void testReceiveMessage() {
    final Gson gson = new Gson();
    final MockNotificationEntity notificationEntity = new MockNotificationEntity();
    final NotificationModel model = new NotificationModel(notificationEntity.createEntity(), Collections.emptyList());
    final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
    final ProjectDataFactory projectDataFactory = Mockito.mock(ProjectDataFactory.class);
    final NotificationEventManager eventManager = Mockito.mock(NotificationEventManager.class);
    final RealTimeListener realTimeListener = new RealTimeListener(gson, channelTemplateManager, projectDataFactory, eventManager);
    final RealTimeEvent realTimeEvent = new RealTimeEvent(Arrays.asList(model));
    final String realTimeEventString = gson.toJson(realTimeEvent);
    realTimeListener.receiveMessage(realTimeEventString);
    Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.any());
    Mockito.verify(channelTemplateManager).sendEvents(Mockito.any());
}
Also used : MockNotificationEntity(com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationEventManager(com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager) Gson(com.google.gson.Gson) RealTimeEvent(com.blackducksoftware.integration.hub.alert.event.RealTimeEvent) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) ProjectDataFactory(com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory) Test(org.junit.Test)

Example 7 with MockNotificationEntity

use of com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity in project hub-alert by blackducksoftware.

the class AuditEntryActionsTest method testResendNotificationException.

@Test
public void testResendNotificationException() {
    final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
    final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
    final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
    final AuditNotificationRepositoryWrapper auditNotificationRepository = Mockito.mock(AuditNotificationRepositoryWrapper.class);
    final CommonDistributionRepositoryWrapper commonDistributionRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
    final MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
    final MockNotificationEntity mockNotificationEntity = new MockNotificationEntity();
    Mockito.when(auditEntryRepository.findOne(Mockito.anyLong())).thenReturn(mockAuditEntryEntity.createEmptyEntity());
    Mockito.when(commonDistributionRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(null);
    Mockito.when(notificationRepository.findAll(Mockito.any())).thenReturn(Arrays.asList(mockNotificationEntity.createEntity()));
    final AuditEntryActions auditEntryActions = new AuditEntryActions(auditEntryRepository, new NotificationManager(notificationRepository, vulnerabilityRepository, auditEntryRepository, auditNotificationRepository), auditNotificationRepository, commonDistributionRepositoryWrapper, null, null, null, null);
    List<AuditEntryRestModel> restModel = null;
    try {
        restModel = auditEntryActions.resendNotification(1L);
        fail();
    } catch (final IllegalArgumentException e) {
        assertTrue(true);
    } catch (final IntegrationException e) {
        fail();
    }
    assertNull(restModel);
}
Also used : AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) MockNotificationEntity(com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity) AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper) MockAuditEntryEntity(com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity) Test(org.junit.Test)

Aggregations

MockNotificationEntity (com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity)7 Test (org.junit.Test)7 MockAuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity)3 AuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryEntity)3 AuditNotificationRelation (com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation)3 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)3 NotificationEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)3 MockCommonDistributionEntity (com.blackducksoftware.integration.hub.alert.mock.entity.MockCommonDistributionEntity)3 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)3 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)2 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)2 AuditNotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper)2 ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)2 CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)2 NotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper)2 VulnerabilityRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)2 NotificationEventManager (com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager)2 ProjectDataFactory (com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory)2 RealTimeEvent (com.blackducksoftware.integration.hub.alert.event.RealTimeEvent)2 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)2