Skip to content

Commit 1257e25

Browse files
authored
Merge pull request #102 from reportportal/EPMRPP-107247
EPMRPP-107247 || merge missed commits
2 parents c576b18 + 37bfa05 commit 1257e25

File tree

7 files changed

+19
-32
lines changed

7 files changed

+19
-32
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ dependencies {
4242
implementation 'com.epam.reportportal:plugin-api'
4343
annotationProcessor 'com.epam.reportportal:plugin-api'
4444
} else {
45-
implementation 'com.github.reportportal:commons-dao:9b8b695'
46-
implementation 'com.github.reportportal:plugin-api:f59b724'
47-
annotationProcessor 'com.github.reportportal:plugin-api:f59b724'
45+
implementation 'com.github.reportportal:commons-dao:ae1f509'
46+
implementation 'com.github.reportportal:plugin-api:e1786c4'
47+
annotationProcessor 'com.github.reportportal:plugin-api:e1786c4'
4848
}
4949

5050
implementation("org.apache.httpcomponents.client5:httpclient5:5.4.2") // supports gzip encoding

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=5.13.1
1+
version=5.13.5
22
description=EPAM Report Portal. Cloud Jira plugin
33
pluginId = JIRA Cloud
44

src/main/java/com/epam/reportportal/extension/jira/command/GetIssueCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private Ticket getTicket(String ticketId, IntegrationParams details) {
8282
issues = client.issueSearchApi().searchForIssuesUsingJql(jql, null, 50, "", null, null, null, null, null);
8383

8484
} catch (Exception e) {
85-
throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, e.getMessage());
85+
throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR);
8686
}
8787
if (CollectionUtils.isNotEmpty(issues.getIssues())) {
8888
return JIRATicketUtils.toTicket(issues.getIssues().getFirst(), CloudJiraProperties.URL.getParam(details)

src/main/java/com/epam/reportportal/extension/jira/command/GetIssueFieldsCommand.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
146146
allowed.add(new AllowedValue(version.getId(), version.getName()));
147147
}
148148
}
149-
if (fieldID.equalsIgnoreCase(PRIORITY_FIELD.getValue()) && issueField.getKey().equals(PRIORITY_FIELD.name())) {
150-
allowed.add(new AllowedValue(issueField.getValue().getKey(), issueField.getValue().getName()));
151-
149+
if (fieldID.equalsIgnoreCase(PRIORITY_FIELD.getValue())) {
150+
allowed = issueField.getValue().getAllowedValues().stream()
151+
.map(value -> (JsonNode) new ObjectMapper().valueToTree(value))
152+
.map(jn -> new AllowedValue(jn.get("id").asText(), jn.get("name").asText()))
153+
.collect(Collectors.toList());
152154
}
153155
if (fieldID.equalsIgnoreCase(ISSUE_TYPE_FIELD.getValue())) {
154156
isRequired = true;

src/main/java/com/epam/reportportal/extension/jira/command/PostTicketCommand.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,16 @@ protected Ticket invokeCommand(Integration integration, Map<String, Object> para
183183
linkIssues(client, issue, linkedIssue);
184184
}
185185

186-
return getTicket(issueKey, integration.getParams(), client)
187-
.orElse(null);
186+
return JIRATicketUtils.toTicket(issue,
187+
CloudJiraProperties.URL.getParam(integration.getParams())
188+
.orElseThrow(() -> new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION,
189+
"Url is not specified.")));
188190

189191
} catch (ReportPortalException e) {
190192
throw e;
191193
} catch (Exception e) {
192194
log.error(e.getMessage());
193-
throw new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION, e.getMessage());
195+
throw new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION);
194196
}
195197
}
196198

@@ -224,21 +226,6 @@ private Map<String, String> findBinaryData(IssueUpdateDetails issueInput) {
224226
return binary;
225227
}
226228

227-
private Optional<Ticket> getTicket(String id, IntegrationParams details, JiraRestClient jiraRestClient) {
228-
SearchResults issues = findIssue(id, jiraRestClient);
229-
if (issues.getTotal() > 0) {
230-
IssueBean issue = jiraRestClient.issuesApi().getIssue(id, null, false, null, null, false, false);
231-
return Optional.of(JIRATicketUtils.toTicket(issue, CloudJiraProperties.URL.getParam(details)
232-
.orElseThrow(() -> new ReportPortalException(UNABLE_INTERACT_WITH_INTEGRATION, "Url is not specified."))));
233-
} else {
234-
return Optional.empty();
235-
}
236-
}
237-
238-
private SearchResults findIssue(String id, JiraRestClient jiraRestClient) {
239-
return jiraRestClient.issueSearchApi().searchForIssuesUsingJql("issue = " + id, null, 50, "", null, null, null, null, null);
240-
}
241-
242229
private void linkIssues(JiraRestClient jiraRestClient, IssueBean issue, PostFormField field) {
243230
String value = CollectionUtils.isNotEmpty(field.getValue()) ? field.getValue().get(0) : "";
244231
if (StringUtils.isNotEmpty(value)) {

src/main/java/com/epam/reportportal/extension/jira/command/TestConnectionCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public Boolean executeCommand(Integration integration, Map<String, Object> param
6161
return jn != null;
6262
} catch (Exception e) {
6363
LOGGER.error("Unable to connect to Cloud Jira: ", e);
64-
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
65-
String.format("Unable to connect to Cloud Jira. Message: %s", e.getMessage()), e);
64+
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Unable to connect to Cloud Jira");
6665
}
6766
}
6867
}

src/main/java/com/epam/reportportal/extension/jira/command/utils/JIRATicketUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,12 @@ public static IssueUpdateDetails toIssueInput(JiraRestClient client, Project jir
128128
continue;
129129
}
130130
if (one.getId().equalsIgnoreCase(IssueField.PRIORITY_FIELD.value)) {
131-
if (IssuePriority.findByName(one.getValue().get(0)) != null) {
132-
issueUpdateDetails.putFieldsItem(IssueField.PRIORITY_FIELD.value, one.getValue().get(0));
133-
}
131+
issueUpdateDetails.putFieldsItem(IssueField.PRIORITY_FIELD.value, Map.entry("name", one.getValue().get(0)));
134132
continue;
135133
}
136134
if (one.getId().equalsIgnoreCase(IssueField.COMPONENTS_FIELD.value)) {
137-
issueUpdateDetails.putFieldsItem(IssueField.COMPONENTS_FIELD.value, one.getValue());
135+
var names = one.getValue().stream().map(field -> Map.entry("name", field)).toList();
136+
issueUpdateDetails.putFieldsItem(IssueField.COMPONENTS_FIELD.getValue(), names);
138137
continue;
139138
}
140139
if (one.getId().equalsIgnoreCase(ASSIGNEE_FIELD.getValue())) {

0 commit comments

Comments
 (0)