use of com.synopsys.integration.jira.common.model.response.PageOfProjectsResponseModel in project hub-alert by blackducksoftware.
the class JiraCloudIssueCreator method retrieveProjectComponent.
private ProjectComponent retrieveProjectComponent() throws AlertException {
String jiraProjectName = distributionDetails.getProjectNameOrKey();
PageOfProjectsResponseModel projectsResponseModel;
try {
projectsResponseModel = projectService.getProjectsByName(jiraProjectName);
} catch (IntegrationException e) {
throw new AlertException("Failed to retrieve projects from Jira", e);
}
return projectsResponseModel.getProjects().stream().filter(project -> jiraProjectName.equals(project.getName()) || jiraProjectName.equals(project.getKey())).findAny().orElseThrow(() -> new AlertException(String.format("Unable to find project matching '%s'", jiraProjectName)));
}
use of com.synopsys.integration.jira.common.model.response.PageOfProjectsResponseModel in project hub-alert by blackducksoftware.
the class JiraCloudIssueCreatorTest method createTestJiraCloudIssueCreator.
private TestJiraCloudIssueCreator createTestJiraCloudIssueCreator(String projectNameOrKey, JiraCloudJobDetailsModel jiraCloudJobDetailsModel) throws IntegrationException {
ProjectService projectService = Mockito.mock(ProjectService.class);
Mockito.when(projectService.getProjectsByName(Mockito.anyString())).thenReturn(new PageOfProjectsResponseModel(List.of(new ProjectComponent("self", "id", "key", projectNameOrKey, null, null, null, null))));
JiraCustomFieldResolver jiraCustomFieldResolver = new JiraCustomFieldResolver(() -> List.of());
JiraIssueCreationRequestCreator jiraIssueCreationRequestCreator = new JiraIssueCreationRequestCreator(jiraCustomFieldResolver);
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
return new TestJiraCloudIssueCreator(jiraCloudJobDetailsModel, projectService, jiraIssueCreationRequestCreator, issueCategoryRetriever);
}
Aggregations