use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class GlobalHubConfigActionsTest method testGetConfig.
@Test
@Override
public void testGetConfig() throws Exception {
final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
Mockito.when(mockedGlobalRepository.findOne(Mockito.anyLong())).thenReturn(getGlobalEntityMockUtil().createGlobalEntity());
Mockito.when(mockedGlobalRepository.findAll()).thenReturn(Arrays.asList(getGlobalEntityMockUtil().createGlobalEntity()));
final GlobalHubConfigEntity databaseEntity = getGlobalEntityMockUtil().createGlobalEntity();
final TestGlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository);
globalProperties.setHubTrustCertificate(null);
globalProperties.setHubUrl(null);
final ObjectTransformer objectTransformer = new ObjectTransformer();
final GlobalHubConfigActions configActions = new GlobalHubConfigActions(mockedGlobalRepository, globalProperties, objectTransformer);
final GlobalHubConfigRestModel defaultRestModel = objectTransformer.databaseEntityToConfigRestModel(databaseEntity, GlobalHubConfigRestModel.class);
final GlobalHubConfigRestModel maskedRestModel = configActions.maskRestModel(defaultRestModel);
List<GlobalHubConfigRestModel> globalConfigsById = configActions.getConfig(1L);
List<GlobalHubConfigRestModel> allGlobalConfigs = configActions.getConfig(null);
assertTrue(globalConfigsById.size() == 1);
assertTrue(allGlobalConfigs.size() == 1);
final GlobalHubConfigRestModel globalConfigById = globalConfigsById.get(0);
final GlobalHubConfigRestModel globalConfig = allGlobalConfigs.get(0);
System.out.println(maskedRestModel.toString());
System.out.println(globalConfigById.toString());
assertEquals(maskedRestModel, globalConfigById);
assertEquals(maskedRestModel, globalConfig);
Mockito.when(mockedGlobalRepository.findOne(Mockito.anyLong())).thenReturn(null);
Mockito.when(mockedGlobalRepository.findAll()).thenReturn(null);
globalConfigsById = configActions.getConfig(1L);
allGlobalConfigs = configActions.getConfig(null);
assertNotNull(globalConfigsById);
assertNotNull(allGlobalConfigs);
assertTrue(globalConfigsById.isEmpty());
assertTrue(allGlobalConfigs.size() == 1);
final GlobalHubConfigRestModel environmentGlobalConfig = allGlobalConfigs.get(0);
assertEquals(maskedRestModel.getHubAlwaysTrustCertificate(), environmentGlobalConfig.getHubAlwaysTrustCertificate());
assertNull(environmentGlobalConfig.getHubApiKey());
assertEquals(maskedRestModel.getHubProxyHost(), environmentGlobalConfig.getHubProxyHost());
assertNull(environmentGlobalConfig.getHubProxyPassword());
assertEquals(maskedRestModel.getHubProxyPort(), environmentGlobalConfig.getHubProxyPort());
assertEquals(maskedRestModel.getHubProxyUsername(), environmentGlobalConfig.getHubProxyUsername());
assertNull(environmentGlobalConfig.getHubTimeout());
assertEquals(maskedRestModel.getHubUrl(), environmentGlobalConfig.getHubUrl());
assertNull(environmentGlobalConfig.getId());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer 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;
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class EmailChannelManagerTest method getChannelManager.
@Override
public EmailGroupManager getChannelManager() {
final EmailGroupChannel mockEmailChannel = Mockito.mock(EmailGroupChannel.class);
final GlobalEmailRepositoryWrapper mockGlobalRepositoryWrapper = Mockito.mock(GlobalEmailRepositoryWrapper.class);
final EmailGroupDistributionRepositoryWrapper mockRepositoryWrapper = Mockito.mock(EmailGroupDistributionRepositoryWrapper.class);
final EmailGroupManager manager = new EmailGroupManager(mockEmailChannel, mockGlobalRepositoryWrapper, mockRepositoryWrapper, new ObjectTransformer());
return manager;
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class SlackChannelManagerTest method getChannelManager.
@Override
public SlackManager getChannelManager() {
final SlackChannel mockSlackChannel = Mockito.mock(SlackChannel.class);
final GlobalSlackRepositoryWrapper mockGlobalRepositoryWrapper = Mockito.mock(GlobalSlackRepositoryWrapper.class);
final SlackDistributionRepositoryWrapper mockSlackRepositoryWrapper = Mockito.mock(SlackDistributionRepositoryWrapper.class);
final SlackManager manager = new SlackManager(mockSlackChannel, mockGlobalRepositoryWrapper, mockSlackRepositoryWrapper, new ObjectTransformer());
return manager;
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigActionsTest method testConfigurationChangeTriggers.
@Override
public void testConfigurationChangeTriggers() {
final AccumulatorConfig mockedAccumulatorConfig = Mockito.mock(AccumulatorConfig.class);
final DailyDigestBatchConfig mockedDailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
final PurgeConfig mockedPurgeConfig = Mockito.mock(PurgeConfig.class);
final GlobalSchedulingRepositoryWrapper globalSchedulingRepository = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
Mockito.when(globalSchedulingRepository.findAll()).thenReturn(Arrays.asList(getGlobalEntityMockUtil().createGlobalEntity()));
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, new ObjectTransformer(), globalProperties, channelTemplateManager, new NotificationManager(notificationRepository, vulnerabilityRepository, null, null));
configActions.configurationChangeTriggers(null);
Mockito.verify(mockedAccumulatorConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedDailyDigestBatchConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedPurgeConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.reset(mockedAccumulatorConfig);
Mockito.reset(mockedDailyDigestBatchConfig);
Mockito.reset(mockedPurgeConfig);
final GlobalSchedulingConfigRestModel restModel = getGlobalRestModelMockUtil().createGlobalRestModel();
configActions.configurationChangeTriggers(restModel);
Mockito.verify(mockedAccumulatorConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedDailyDigestBatchConfig, Mockito.times(1)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedPurgeConfig, Mockito.times(1)).scheduleJobExecution(Mockito.any());
}
Aggregations