Search in sources :

Example 6 with GlobalProperties

use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.

the class GlobalHubConfigActionsTest method getMockedConfigActions.

@Override
public GlobalHubConfigActions getMockedConfigActions() {
    final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
    final GlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository);
    final GlobalHubConfigActions configActions = new GlobalHubConfigActions(mockedGlobalRepository, globalProperties, new ObjectTransformer());
    return configActions;
}
Also used : GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ObjectTransformer(com.blackducksoftware.integration.hub.alert.web.ObjectTransformer) GlobalHubConfigActions(com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties)

Example 7 with GlobalProperties

use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.

the class GlobalHubConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.

@Override
public GlobalHubConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
    final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
    final GlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository);
    final GlobalHubConfigActions configActions = new GlobalHubConfigActions(mockedGlobalRepository, globalProperties, objectTransformer);
    return configActions;
}
Also used : GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) GlobalHubConfigActions(com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties)

Example 8 with GlobalProperties

use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.

the class AccumulatorReaderTest method testRead.

@Test
public void testRead() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
    final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
    final NotificationService notificationService = Mockito.mock(NotificationService.class);
    final SortedSet<NotificationContentItem> notificationContentItems = new TreeSet<>();
    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 NotificationContentItem notificationContentItem = new NotificationContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentVersionUrl, componentIssueUrl);
    notificationContentItems.add(notificationContentItem);
    final NotificationResults notificationResults = new NotificationResults(notificationContentItems, null);
    Mockito.doReturn(hubServicesFactory).when(globalProperties).createHubServicesFactoryAndLogErrors(Mockito.any());
    Mockito.doReturn(notificationService).when(hubServicesFactory).createNotificationService();
    Mockito.doReturn(notificationResults).when(notificationService).getAllNotificationResults(Mockito.any(), Mockito.any());
    final AccumulatorReader accumulatorReader = new AccumulatorReader(globalProperties);
    final NotificationResults actualNotificationResults = accumulatorReader.read();
    assertNotNull(actualNotificationResults);
}
Also used : NotificationContentItem(com.blackducksoftware.integration.hub.notification.NotificationContentItem) NotificationResults(com.blackducksoftware.integration.hub.notification.NotificationResults) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) TreeSet(java.util.TreeSet) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory) NotificationService(com.blackducksoftware.integration.hub.service.NotificationService) ComponentVersionView(com.blackducksoftware.integration.hub.api.generated.view.ComponentVersionView) ProjectVersionModel(com.blackducksoftware.integration.hub.notification.ProjectVersionModel) Date(java.util.Date) Test(org.junit.Test)

Example 9 with GlobalProperties

use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.

the class DistributionChannelTest method handleEventWrongTypeTest.

@Test
public void handleEventWrongTypeTest() {
    final GlobalProperties globalProperties = new TestGlobalProperties();
    final Gson gson = new Gson();
    final CommonDistributionRepositoryWrapper commonRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
    final EmailGroupChannel channel = new EmailGroupChannel(globalProperties, gson, null, null, null, commonRepositoryWrapper);
    final Long commonId = 1L;
    final EmailGroupEvent event = new EmailGroupEvent(createProjectData("Distribution Channel Test"), commonId);
    final CommonDistributionConfigEntity commonEntity = new CommonDistributionConfigEntity(commonId, SupportedChannels.SLACK, "Other Config", DigestTypeEnum.REAL_TIME, false);
    Mockito.when(commonRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(commonEntity);
    channel.handleEvent(event);
}
Also used : CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) EmailGroupEvent(com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupEvent) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) EmailGroupChannel(com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel) Gson(com.google.gson.Gson) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test)

Example 10 with GlobalProperties

use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.

the class GlobalSchedulingConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.

@Override
public GlobalSchedulingConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
    final AccumulatorConfig mockedAccumulatorConfig = Mockito.mock(AccumulatorConfig.class);
    Mockito.when(mockedAccumulatorConfig.getMillisecondsToNextRun()).thenReturn(33000l);
    final DailyDigestBatchConfig mockedDailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
    Mockito.when(mockedDailyDigestBatchConfig.getFormatedNextRunTime()).thenReturn("01/19/2018 02:00 AM UTC");
    final PurgeConfig mockedPurgeConfig = Mockito.mock(PurgeConfig.class);
    Mockito.when(mockedPurgeConfig.getFormatedNextRunTime()).thenReturn("01/21/2018 12:00 AM UTC");
    final GlobalSchedulingRepositoryWrapper globalSchedulingRepository = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
    final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
    final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
    final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
    final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
    final GlobalSchedulingConfigActions configActions = new GlobalSchedulingConfigActions(mockedAccumulatorConfig, mockedDailyDigestBatchConfig, mockedPurgeConfig, globalSchedulingRepository, objectTransformer, globalProperties, channelTemplateManager, new NotificationManager(notificationRepository, vulnerabilityRepository, null, null));
    return configActions;
}
Also used : NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) AccumulatorConfig(com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig) GlobalSchedulingRepositoryWrapper(com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) PurgeConfig(com.blackducksoftware.integration.hub.alert.config.PurgeConfig) DailyDigestBatchConfig(com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)

Aggregations

GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)17 Test (org.junit.Test)13 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)8 Logger (org.slf4j.Logger)6 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)5 HubService (com.blackducksoftware.integration.hub.service.HubService)4 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)3 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)2 ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)2 EmailGroupChannel (com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel)2 EmailGroupEvent (com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupEvent)2 AccumulatorConfig (com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig)2 DailyDigestBatchConfig (com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig)2 PurgeConfig (com.blackducksoftware.integration.hub.alert.config.PurgeConfig)2 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)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 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)2 GlobalHubConfigActions (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions)2