Search in sources :

Example 1 with PageOfProjectsResponseModel

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)));
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) PageOfProjectsResponseModel(com.synopsys.integration.jira.common.model.response.PageOfProjectsResponseModel) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Example 2 with PageOfProjectsResponseModel

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);
}
Also used : ProjectComponent(com.synopsys.integration.jira.common.model.components.ProjectComponent) JiraCustomFieldResolver(com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver) JiraIssueCreationRequestCreator(com.synopsys.integration.alert.api.channel.jira.distribution.JiraIssueCreationRequestCreator) ProjectService(com.synopsys.integration.jira.common.cloud.service.ProjectService) PageOfProjectsResponseModel(com.synopsys.integration.jira.common.model.response.PageOfProjectsResponseModel) IssueCategoryRetriever(com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)

Aggregations

PageOfProjectsResponseModel (com.synopsys.integration.jira.common.model.response.PageOfProjectsResponseModel)2 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)1 JiraIssueCreationRequestCreator (com.synopsys.integration.alert.api.channel.jira.distribution.JiraIssueCreationRequestCreator)1 JiraCustomFieldResolver (com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver)1 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 ProjectService (com.synopsys.integration.jira.common.cloud.service.ProjectService)1 ProjectComponent (com.synopsys.integration.jira.common.model.components.ProjectComponent)1