|
21 | 21 | import com.epam.reportportal.extension.jira.command.utils.CloudJiraClientProvider; |
22 | 22 | import com.epam.reportportal.extension.jira.command.utils.CloudJiraProperties; |
23 | 23 | import com.epam.reportportal.extension.jira.command.utils.JIRATicketUtils; |
24 | | -import com.epam.reportportal.model.externalsystem.Ticket; |
25 | | -import com.epam.reportportal.rules.exception.ErrorType; |
26 | | -import com.epam.reportportal.rules.exception.ReportPortalException; |
27 | | -import com.epam.ta.reportportal.dao.IntegrationRepository; |
28 | | -import com.epam.ta.reportportal.dao.TicketRepository; |
29 | | -import com.epam.ta.reportportal.entity.integration.Integration; |
30 | | -import com.epam.ta.reportportal.entity.integration.IntegrationParams; |
| 24 | +import com.epam.reportportal.infrastructure.model.externalsystem.Ticket; |
| 25 | +import com.epam.reportportal.infrastructure.persistence.dao.IntegrationRepository; |
| 26 | +import com.epam.reportportal.infrastructure.persistence.dao.TicketRepository; |
| 27 | +import com.epam.reportportal.infrastructure.persistence.entity.integration.Integration; |
| 28 | +import com.epam.reportportal.infrastructure.persistence.entity.integration.IntegrationParams; |
| 29 | +import com.epam.reportportal.infrastructure.rules.exception.ErrorType; |
| 30 | +import com.epam.reportportal.infrastructure.rules.exception.ReportPortalException; |
31 | 31 | import java.util.Map; |
32 | 32 | import java.util.Optional; |
33 | 33 | import org.apache.commons.collections4.CollectionUtils; |
@@ -57,36 +57,42 @@ public Ticket executeCommand(Map<String, Object> params) { |
57 | 57 | var ticketId = Optional.ofNullable(params.get(TICKET_ID)) |
58 | 58 | .map(String::valueOf) |
59 | 59 | .orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, TICKET_ID + " must be provided")); |
60 | | - final com.epam.ta.reportportal.entity.bts.Ticket ticket = ticketRepository.findByTicketId(ticketId) |
61 | | - .orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Ticket not found with id " + TICKET_ID)); |
| 60 | + var ticket = ticketRepository.findByTicketId(ticketId) |
| 61 | + .orElseThrow( |
| 62 | + () -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Ticket not found with id " + TICKET_ID)); |
62 | 63 | final Long projectId = (Long) Optional.ofNullable(params.get(PROJECT_ID)) |
63 | 64 | .orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, PROJECT_ID + " must be provided")); |
64 | 65 |
|
65 | 66 | final String btsUrl = CloudJiraProperties.URL.getParam(params) |
66 | | - .orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Url is not specified.")); |
| 67 | + .orElseThrow( |
| 68 | + () -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Url is not specified.")); |
67 | 69 | final String btsProject = CloudJiraProperties.PROJECT.getParam(params) |
68 | | - .orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Project is not specified.")); |
| 70 | + .orElseThrow( |
| 71 | + () -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Project is not specified.")); |
69 | 72 |
|
70 | 73 | final Integration integration = |
71 | 74 | integrationRepository.findProjectBtsByUrlAndLinkedProject(btsUrl, btsProject, projectId) |
72 | 75 | .orElseGet(() -> integrationRepository.findGlobalBtsByUrlAndLinkedProject(btsUrl, btsProject) |
73 | | - .orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Integration with provided url and project isn't found"))); |
| 76 | + .orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, |
| 77 | + "Integration with provided url and project isn't found"))); |
74 | 78 | return getTicket(ticketId, integration.getParams()); |
75 | 79 | } |
76 | 80 |
|
77 | 81 | private Ticket getTicket(String ticketId, IntegrationParams details) { |
78 | 82 | var client = cloudJiraClientProvider.getApiClient(details); |
79 | 83 | SearchResults issues; |
80 | 84 | try { |
81 | | - var jql = String.format("project=%s and key=%s", CloudJiraProperties.PROJECT.getParam(details.getParams()).get(), ticketId); |
| 85 | + var jql = String.format("project=%s and key=%s", CloudJiraProperties.PROJECT.getParam(details.getParams()).get(), |
| 86 | + ticketId); |
82 | 87 | issues = client.issueSearchApi().searchForIssuesUsingJql(jql, null, 50, "", null, null, null, null, null); |
83 | 88 |
|
84 | 89 | } catch (Exception e) { |
85 | 90 | throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR); |
86 | 91 | } |
87 | 92 | if (CollectionUtils.isNotEmpty(issues.getIssues())) { |
88 | 93 | return JIRATicketUtils.toTicket(issues.getIssues().getFirst(), CloudJiraProperties.URL.getParam(details) |
89 | | - .orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Url is not specified."))); |
| 94 | + .orElseThrow( |
| 95 | + () -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Url is not specified."))); |
90 | 96 | } else { |
91 | 97 | throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Ticket with id {} is not found", ticketId); |
92 | 98 | } |
|
0 commit comments