Skip to content

Commit

Permalink
Release 5.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
APiankouski authored Sep 23, 2024
2 parents 3c77541 + b35904d commit 91c9461
Show file tree
Hide file tree
Showing 25 changed files with 6,391 additions and 5,402 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:

env:
GH_USER_NAME: github.actor
SCRIPTS_VERSION: 5.10.0
BOM_VERSION: 5.11.0
SCRIPTS_VERSION: 5.12.0
BOM_VERSION: 5.12.1

jobs:
release:
Expand Down
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@ repositories {

dependencyManagement {
imports {
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:5.11.2' : 'com.epam.reportportal:commons-bom:5.11.2')
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:5.12.1' : 'com.epam.reportportal:commons-bom:5.12.1')
}
}

dependencies {
if (releaseMode) {
implementation 'com.epam.reportportal:commons-dao'
implementation 'com.epam.reportportal:plugin-api'
annotationProcessor 'com.epam.reportportal:plugin-api'
} else {
implementation 'com.epam.reportportal:plugin-api'
annotationProcessor 'com.epam.reportportal:plugin-api'
implementation 'com.github.reportportal:commons-dao:acf1ec7'
implementation 'com.github.reportportal:plugin-api:188792e'
annotationProcessor 'com.github.reportportal:plugin-api:188792e'
}
implementation 'org.hibernate:hibernate-core:5.6.15.Final'

implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
implementation group: 'org.jooq', name: 'jooq', version: '3.14.4'
jooqRuntime 'org.postgresql:postgresql:42.2.13'
jooqRuntime 'org.postgresql:postgresql:42.7.3'

compile 'ch.qos.logback:logback-classic:1.2.3'
compile 'org.slf4j:slf4j-api:1.7.25'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=5.11.2
version=5.12.1
description=EPAM Report Portal. Cloud Jira plugin
pluginId = JIRA Cloud
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.epam.reportportal.extension.jira.command.GetIssueTypesCommand;
import com.epam.reportportal.extension.jira.command.PostTicketCommand;
import com.epam.reportportal.extension.jira.command.RetrieveCreationParamsCommand;
import com.epam.reportportal.extension.jira.command.UserSearchCommand;
import com.epam.reportportal.extension.jira.command.atlassian.CloudJiraClientProviderExtended;
import com.epam.reportportal.extension.jira.command.RetrieveUpdateParamsCommand;
import com.epam.reportportal.extension.jira.command.connection.TestConnectionCommand;
Expand Down Expand Up @@ -231,6 +232,7 @@ private Map<String, CommonPluginCommand<?>> getCommonCommands() {

private Map<String, PluginCommand<?>> getCommands() {
List<PluginCommand<?>> commands = new ArrayList<>();
commands.add(new UserSearchCommand(projectRepository, cloudJiraClientProviderSupplier.get()));
commands.add(new TestConnectionCommand(cloudJiraClientProviderSupplier.get()));
commands.add(new GetIssueFieldsCommand(projectRepository, cloudJiraClientProviderExtendedSupplier.get()));
commands.add(new GetIssueTypesCommand(projectRepository, cloudJiraClientProviderSupplier.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
import com.epam.reportportal.extension.jira.command.utils.CloudJiraClientProvider;
import com.epam.reportportal.extension.jira.command.utils.CloudJiraProperties;
import com.epam.reportportal.extension.jira.command.utils.JIRATicketUtils;
import com.epam.reportportal.model.externalsystem.Ticket;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.dao.TicketRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.integration.IntegrationParams;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.externalsystem.Ticket;

import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.reportportal.rules.exception.ErrorType;
import java.util.Map;
import java.util.Optional;

Expand All @@ -39,64 +38,80 @@
*/
public class GetIssueCommand implements CommonPluginCommand<Ticket> {

private final String TICKET_ID = "ticketId";
private final String PROJECT_ID = "projectId";
private final String TICKET_ID = "ticketId";
private final String PROJECT_ID = "projectId";

private final TicketRepository ticketRepository;
private final IntegrationRepository integrationRepository;
private final CloudJiraClientProvider cloudJiraClientProvider;
private final TicketRepository ticketRepository;
private final IntegrationRepository integrationRepository;
private final CloudJiraClientProvider cloudJiraClientProvider;

public GetIssueCommand(TicketRepository ticketRepository, IntegrationRepository integrationRepository,
CloudJiraClientProvider cloudJiraClientProvider) {
this.ticketRepository = ticketRepository;
this.integrationRepository = integrationRepository;
this.cloudJiraClientProvider = cloudJiraClientProvider;
}
public GetIssueCommand(TicketRepository ticketRepository,
IntegrationRepository integrationRepository,
CloudJiraClientProvider cloudJiraClientProvider) {
this.ticketRepository = ticketRepository;
this.integrationRepository = integrationRepository;
this.cloudJiraClientProvider = cloudJiraClientProvider;
}

@Override
public Ticket executeCommand(Map<String, Object> params) {
final com.epam.ta.reportportal.entity.bts.Ticket ticket = ticketRepository.findByTicketId((String) Optional.ofNullable(params.get(
TICKET_ID)).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, TICKET_ID + " must be provided")))
.orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Ticket not found with id " + TICKET_ID));
final Long projectId = (Long) Optional.ofNullable(params.get(PROJECT_ID))
.orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, PROJECT_ID + " must be provided"));
@Override
public Ticket executeCommand(Map<String, Object> params) {
final com.epam.ta.reportportal.entity.bts.Ticket ticket = ticketRepository.findByTicketId(
(String) Optional.ofNullable(params.get(TICKET_ID)).orElseThrow(
() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR,
TICKET_ID + " must be provided"
))).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR,
"Ticket not found with id " + TICKET_ID
));
final Long projectId = (Long) Optional.ofNullable(params.get(PROJECT_ID)).orElseThrow(
() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR,
PROJECT_ID + " must be provided"
));

final String btsUrl = CloudJiraProperties.URL.getParam(params)
.orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Url is not specified."));
final String btsProject = CloudJiraProperties.PROJECT.getParam(params)
.orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Project is not specified."));
final String btsUrl = CloudJiraProperties.URL.getParam(params).orElseThrow(
() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
"Url is not specified."
));
final String btsProject = CloudJiraProperties.PROJECT.getParam(params).orElseThrow(
() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
"Project is not specified."
));

final Integration integration = integrationRepository.findProjectBtsByUrlAndLinkedProject(btsUrl, btsProject, projectId)
.orElseGet(() -> integrationRepository.findGlobalBtsByUrlAndLinkedProject(btsUrl, btsProject)
.orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR,
"Integration with provided url and project isn't found"
)));
return getTicket(ticket.getTicketId(), integration.getParams(), cloudJiraClientProvider.get(integration.getParams()));
}
final Integration integration =
integrationRepository.findProjectBtsByUrlAndLinkedProject(btsUrl, btsProject, projectId)
.orElseGet(
() -> integrationRepository.findGlobalBtsByUrlAndLinkedProject(btsUrl, btsProject)
.orElseThrow(() -> new ReportPortalException(
ErrorType.BAD_REQUEST_ERROR,
"Integration with provided url and project isn't found"
)));
return getTicket(
ticket.getTicketId(), integration.getParams(),
cloudJiraClientProvider.get(integration.getParams())
);
}

private Ticket getTicket(String id, IntegrationParams details, JiraRestClient jiraRestClient) {
SearchResult issues;
try {
issues = jiraRestClient.getSearchClient().searchJql("issue = " + id).claim();
} catch (Exception e) {
throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, e.getMessage());
}
if (issues != null && issues.getTotal() > 0) {
Issue issue = jiraRestClient.getIssueClient().getIssue(id).claim();
return JIRATicketUtils.toTicket(issue,
CloudJiraProperties.URL.getParam(details)
.orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
"Url is not specified."
))
);
} else {
throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Ticket with id {} is not found", id);
}
private Ticket getTicket(String id, IntegrationParams details, JiraRestClient jiraRestClient) {
SearchResult issues;
try {
issues = jiraRestClient.getSearchClient().searchJql("issue = " + id).claim();
} catch (Exception e) {
throw new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, e.getMessage());
}
if (issues != null && issues.getTotal() > 0) {
Issue issue = jiraRestClient.getIssueClient().getIssue(id).claim();
return JIRATicketUtils.toTicket(issue, CloudJiraProperties.URL.getParam(details).orElseThrow(
() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
"Url is not specified."
)));
} else {
throw new ReportPortalException(
ErrorType.BAD_REQUEST_ERROR, "Ticket with id {} is not found", id);
}

}
}

@Override
public String getName() {
return "getIssue";
}
@Override
public String getName() {
return "getIssue";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import com.epam.reportportal.extension.ProjectManagerCommand;
import com.epam.reportportal.extension.jira.command.utils.CloudJiraClientProvider;
import com.epam.reportportal.extension.jira.command.utils.CloudJiraProperties;
import com.epam.reportportal.model.externalsystem.AllowedValue;
import com.epam.reportportal.model.externalsystem.PostFormField;
import com.epam.reportportal.rules.commons.validation.BusinessRule;
import com.epam.ta.reportportal.commons.Preconditions;
import com.epam.ta.reportportal.commons.validation.BusinessRule;
import com.epam.ta.reportportal.dao.ProjectRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.externalsystem.AllowedValue;
import com.epam.ta.reportportal.ws.model.externalsystem.PostFormField;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.reportportal.rules.exception.ErrorType;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -96,6 +97,7 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
String fieldType = issueField.getSchema().getType();
boolean isRequired = issueField.isRequired();
List<AllowedValue> allowed = new ArrayList<>();
String commandName = null;

// Provide values for custom fields with predefined options
if (issueField.getAllowedValues() != null) {
Expand Down Expand Up @@ -140,6 +142,7 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
}
if (fieldID.equalsIgnoreCase(IssueFieldId.ASSIGNEE_FIELD.id)) {
allowed = getJiraProjectAssignee(jiraProject);
commandName = "searchUsers";
}

//@formatter:off
Expand All @@ -156,7 +159,12 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
continue;
}

result.add(new PostFormField(fieldID, fieldName, fieldType, isRequired, defValue, allowed));
PostFormField postForm = new PostFormField(fieldID, fieldName, fieldType, isRequired, defValue,
allowed);
if (StringUtils.isNotEmpty(commandName)) {
postForm.setCommandName(commandName);
}
result.add(postForm);
}
return result;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.epam.reportportal.extension.jira.command;

import com.atlassian.jira.rest.client.api.JiraRestClient;
Expand All @@ -23,9 +24,8 @@
import com.epam.reportportal.extension.jira.command.utils.CloudJiraProperties;
import com.epam.ta.reportportal.dao.ProjectRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;

import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.reportportal.rules.exception.ErrorType;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -36,32 +36,32 @@
*/
public class GetIssueTypesCommand extends ProjectManagerCommand<List<String>> {

private final CloudJiraClientProvider cloudJiraClientProvider;
private final CloudJiraClientProvider cloudJiraClientProvider;

public GetIssueTypesCommand(ProjectRepository projectRepository, CloudJiraClientProvider cloudJiraClientProvider) {
super(projectRepository);
this.cloudJiraClientProvider = cloudJiraClientProvider;
}
public GetIssueTypesCommand(ProjectRepository projectRepository,
CloudJiraClientProvider cloudJiraClientProvider) {
super(projectRepository);
this.cloudJiraClientProvider = cloudJiraClientProvider;
}

@Override
public String getName() {
return "getIssueTypes";
}
@Override
public String getName() {
return "getIssueTypes";
}

@Override
protected List<String> invokeCommand(Integration integration, Map<String, Object> params) {
try (JiraRestClient client = cloudJiraClientProvider.get(integration.getParams())) {
Project jiraProject = client.getProjectClient()
.getProject(CloudJiraProperties.PROJECT.getParam(integration.getParams())
.orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
"Project is not specified."
)))
.claim();
return StreamSupport.stream(jiraProject.getIssueTypes().spliterator(), false)
.map(IssueType::getName)
.collect(Collectors.toList());
} catch (Exception e) {
throw new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Check connection settings.");
}
}
@Override
protected List<String> invokeCommand(Integration integration, Map<String, Object> params) {
try (JiraRestClient client = cloudJiraClientProvider.get(integration.getParams())) {
Project jiraProject = client.getProjectClient().getProject(
CloudJiraProperties.PROJECT.getParam(integration.getParams()).orElseThrow(
() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION,
"Project is not specified."
))).claim();
return StreamSupport.stream(jiraProject.getIssueTypes().spliterator(), false)
.map(IssueType::getName).collect(Collectors.toList());
} catch (Exception e) {
throw new ReportPortalException(
ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Check connection settings.");
}
}
}
Loading

0 comments on commit 91c9461

Please sign in to comment.