use of com.blackducksoftware.integration.hub.alert.hub.model.HubProject 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.alert.hub.model.HubProject 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());
}
use of com.blackducksoftware.integration.hub.alert.hub.model.HubProject in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubProjects.
@Test
public void testGetHubProjects() 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);
final List<ProjectView> projectViews = new ArrayList<>();
final String projectName = "projectName";
final ProjectView projectView = new ProjectView();
projectView.name = projectName;
projectViews.add(projectView);
Mockito.when(hubService.getAllResponses(ApiDiscovery.PROJECTS_LINK_RESPONSE)).thenReturn(projectViews);
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(1, hubProjects.size());
final HubProject hubProject = hubProjects.get(0);
assertEquals(projectName, hubProject.getName());
}
Aggregations