use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class TestGlobalProperties method createHubServicesFactoryWithCredential.
public HubServicesFactory createHubServicesFactoryWithCredential(final IntLogger logger) throws Exception {
setHubUrl(testProperties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
setHubTrustCertificate(true);
final HubServerConfig hubServerConfig = createHubServerConfigWithCredentials(logger);
final RestConnection restConnection = hubServerConfig.createCredentialsRestConnection(logger);
return new HubServicesFactory(restConnection);
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubGroupsNoGroups.
@Test
public void testGetHubGroupsNoGroups() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
final HubService hubService = Mockito.mock(HubService.class);
Mockito.when(hubService.getAllResponses(ApiDiscovery.USERGROUPS_LINK_RESPONSE)).thenReturn(Collections.emptyList());
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(0, hubGroups.size());
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class HubDataActions method getHubProjects.
public List<HubProject> getHubProjects() throws IntegrationException {
final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactory(logger);
if (hubServicesFactory != null) {
final List<ProjectView> rawProjects = hubServicesFactory.createHubService().getAllResponses(ApiDiscovery.PROJECTS_LINK_RESPONSE);
final List<HubProject> projects = new ArrayList<>();
for (final ProjectView projectView : rawProjects) {
final HubProject project = new HubProject(projectView.name);
projects.add(project);
}
return projects;
} else {
throw new AlertException("Missing global configuration.");
}
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class DailyItemReader method phoneHome.
private PhoneHomeResponse phoneHome() {
final String productVersion = globalProperties.getProductVersion();
if (!GlobalProperties.PRODUCT_VERSION_UNKNOWN.equals(productVersion)) {
final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactoryAndLogErrors(logger);
final PhoneHomeService phoneHomeService = hubServicesFactory.createPhoneHomeService();
final PhoneHomeRequestBodyBuilder phoneHomeRequestBodyBuilder = phoneHomeService.createInitialPhoneHomeRequestBodyBuilder(ThirdPartyName.ALERT, productVersion, productVersion);
final PhoneHomeRequestBody phoneHomeRequestBody = phoneHomeRequestBodyBuilder.build();
return phoneHomeService.startPhoneHome(phoneHomeRequestBody);
} else {
return null;
}
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class VulnerabilityCacheTest method testRemoveEvent.
@Test
public void testRemoveEvent() {
final ProjectService mockedProjectService = Mockito.mock(ProjectService.class);
final HubService mockedHubService = Mockito.mock(HubService.class);
final ComponentService mockedComponentService = Mockito.mock(ComponentService.class);
final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
final VulnerabilityCache vulnerabilityCache = new VulnerabilityCache(mockedProjectService, hubServicesFactory);
Mockito.when(hubServicesFactory.createProjectService()).thenReturn(mockedProjectService);
Mockito.when(hubServicesFactory.createHubService()).thenReturn(mockedHubService);
Mockito.when(hubServicesFactory.createComponentService()).thenReturn(mockedComponentService);
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));
dataSet.put(VulnerabilityCache.VULNERABILITY_ID_SET, new HashSet<String>());
final NotificationEvent notificationEvent = new NotificationEvent("key", NotificationCategoryEnum.HIGH_VULNERABILITY, dataSet);
assumeTrue(vulnerabilityCache.getEventMap().size() == 0);
vulnerabilityCache.removeEvent(notificationEvent);
assumeTrue(vulnerabilityCache.getEventMap().size() == 1);
vulnerabilityCache.removeEvent(notificationEvent);
assumeTrue(vulnerabilityCache.getEventMap().size() == 0);
}
Aggregations