use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties 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());
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class LoginActionsTestIT method testIsUserValidFailIT.
@Test
public void testIsUserValidFailIT() throws IntegrationException, IOException {
final LoginRestModel loginRestModel = mockLoginRestModel.createRestModel();
final GlobalProperties globalProperties = new TestGlobalProperties();
final HubServerConfigBuilder serverConfigBuilder = new HubServerConfigBuilder();
serverConfigBuilder.setLogger(new Slf4jIntLogger(logger));
serverConfigBuilder.setHubUrl(globalProperties.getHubUrl());
serverConfigBuilder.setAlwaysTrustServerCertificate(globalProperties.getHubTrustCertificate());
serverConfigBuilder.setTimeout(globalProperties.getHubTimeout());
serverConfigBuilder.setPassword(loginRestModel.getHubPassword());
serverConfigBuilder.setUsername(loginRestModel.getHubUsername());
final LoginActions loginActions = new LoginActions(globalProperties);
final RestConnection restConnection = loginActions.createRestConnection(serverConfigBuilder);
final boolean roleValid = loginActions.isUserRoleValid("broken", restConnection);
assertFalse(roleValid);
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubGroups.
@Test
public void testGetHubGroups() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
final HubService hubService = Mockito.mock(HubService.class);
final List<UserGroupView> userGroups = new ArrayList<>();
final Boolean active = true;
final String username = "User";
final String href = "href";
final UserGroupView userGroup = new UserGroupView();
final ResourceMetadata metaView = new ResourceMetadata();
metaView.href = href;
userGroup._meta = metaView;
userGroup.active = active;
userGroup.name = username;
userGroups.add(userGroup);
Mockito.when(hubService.getAllResponses(ApiDiscovery.USERGROUPS_LINK_RESPONSE)).thenReturn(userGroups);
Mockito.when(hubServicesFactory.createHubService()).thenReturn(hubService);
Mockito.when(hubServicesFactory.createHubService()).thenReturn(hubService);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(hubServicesFactory);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
final List<HubGroup> hubGroups = hubDataActions.getHubGroups();
assertEquals(1, hubGroups.size());
final HubGroup hubGroup = hubGroups.get(0);
assertEquals(active, hubGroup.getActive());
assertEquals(username, hubGroup.getName());
assertEquals(href, hubGroup.getUrl());
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubProjectsNullHubServicesFactory.
@Test
public void testGetHubProjectsNullHubServicesFactory() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(null);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
try {
hubDataActions.getHubProjects();
fail();
} catch (final AlertException e) {
assertEquals("Missing global configuration.", e.getMessage());
}
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubProjectsNoProjects.
@Test
public void testGetHubProjectsNoProjects() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
final ProjectService projectRequestService = Mockito.mock(ProjectService.class);
final HubService hubService = Mockito.mock(HubService.class);
Mockito.when(hubService.getAllResponses(ApiDiscovery.PROJECTS_LINK_RESPONSE)).thenReturn(Collections.emptyList());
Mockito.when(hubServicesFactory.createProjectService()).thenReturn(projectRequestService);
Mockito.when(hubServicesFactory.createHubService()).thenReturn(hubService);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(hubServicesFactory);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
final List<HubProject> hubProjects = hubDataActions.getHubProjects();
assertEquals(0, hubProjects.size());
}
Aggregations