Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-89665 || Update error message when UPSA user is assigned to UPSA project #1978

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@

package com.epam.ta.reportportal.core.project.impl;

import static com.epam.reportportal.rules.commons.validation.BusinessRule.expect;
import static com.epam.reportportal.rules.commons.validation.BusinessRule.fail;
import static com.epam.reportportal.rules.commons.validation.Suppliers.formattedSupplier;
import static com.epam.reportportal.rules.exception.ErrorType.ACCESS_DENIED;
import static com.epam.reportportal.rules.exception.ErrorType.BAD_REQUEST_ERROR;
import static com.epam.reportportal.rules.exception.ErrorType.PROJECT_NOT_FOUND;
import static com.epam.reportportal.rules.exception.ErrorType.ROLE_NOT_FOUND;
import static com.epam.reportportal.rules.exception.ErrorType.UNABLE_ASSIGN_UNASSIGN_USER_TO_PROJECT;
import static com.epam.reportportal.rules.exception.ErrorType.USER_NOT_FOUND;
import static com.epam.ta.reportportal.commons.EntityUtils.normalizeId;
import static com.epam.ta.reportportal.commons.Preconditions.contains;
import static com.epam.ta.reportportal.commons.Predicates.equalTo;
Expand All @@ -24,24 +33,18 @@
import static com.epam.ta.reportportal.commons.Predicates.isPresent;
import static com.epam.ta.reportportal.commons.Predicates.not;
import static com.epam.ta.reportportal.commons.Predicates.notNull;
import static com.epam.reportportal.rules.commons.validation.BusinessRule.expect;
import static com.epam.reportportal.rules.commons.validation.BusinessRule.fail;
import static com.epam.reportportal.rules.commons.validation.Suppliers.formattedSupplier;
import static com.epam.ta.reportportal.core.analyzer.auto.impl.AnalyzerStatusCache.AUTO_ANALYZER_KEY;
import static com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum.AUTO_PATTERN_ANALYZER_ENABLED;
import static com.epam.ta.reportportal.entity.enums.SendCase.findByName;
import static com.epam.ta.reportportal.ws.converter.converters.ProjectActivityConverter.TO_ACTIVITY_RESOURCE;
import static com.epam.reportportal.rules.exception.ErrorType.ACCESS_DENIED;
import static com.epam.reportportal.rules.exception.ErrorType.BAD_REQUEST_ERROR;
import static com.epam.reportportal.rules.exception.ErrorType.PROJECT_NOT_FOUND;
import static com.epam.reportportal.rules.exception.ErrorType.ROLE_NOT_FOUND;
import static com.epam.reportportal.rules.exception.ErrorType.UNABLE_ASSIGN_UNASSIGN_USER_TO_PROJECT;
import static com.epam.reportportal.rules.exception.ErrorType.USER_NOT_FOUND;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;

import com.epam.reportportal.extension.event.ProjectEvent;
import com.epam.reportportal.model.ValidationConstraints;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.commons.Preconditions;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.core.analyzer.auto.LogIndexer;
Expand Down Expand Up @@ -76,7 +79,6 @@
import com.epam.ta.reportportal.entity.user.User;
import com.epam.ta.reportportal.entity.user.UserRole;
import com.epam.ta.reportportal.entity.user.UserType;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.model.activity.ProjectAttributesActivityResource;
import com.epam.ta.reportportal.model.activity.UserActivityResource;
import com.epam.ta.reportportal.model.project.AssignUsersRQ;
Expand All @@ -92,10 +94,8 @@
import com.epam.ta.reportportal.ws.converter.converters.NotificationConfigConverter;
import com.epam.ta.reportportal.ws.converter.converters.ProjectConverter;
import com.epam.ta.reportportal.ws.converter.converters.UserConverter;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.ta.reportportal.ws.reporting.OperationCompletionRS;
import com.epam.reportportal.model.ValidationConstraints;
import com.epam.ta.reportportal.ws.reporting.ItemAttributeResource;
import com.epam.ta.reportportal.ws.reporting.OperationCompletionRS;
import com.google.common.cache.Cache;
import com.google.common.collect.Lists;
import java.util.List;
Expand Down Expand Up @@ -391,7 +391,10 @@ private void assignUser(String name, ProjectRole projectRole, List<String> assig
);
if (ProjectType.UPSA.equals(project.getProjectType()) && UserType.UPSA.equals(
modifyingUser.getUserType())) {
fail().withError(UNABLE_ASSIGN_UNASSIGN_USER_TO_PROJECT, "Project and user has UPSA type!");
fail().withError(
UNABLE_ASSIGN_UNASSIGN_USER_TO_PROJECT,
"Please verify user assignment to the project in EPAM internal system: delivery.epam.com"
);
}
ProjectUser projectUser = new ProjectUser();
projectUser.setProjectRole(projectRole);
Expand All @@ -418,7 +421,10 @@ private void validateUnassigningUser(User modifier, User userForUnassign, Long p
}
if (ProjectType.UPSA.equals(project.getProjectType()) && UserType.UPSA.equals(
userForUnassign.getUserType())) {
fail().withError(UNABLE_ASSIGN_UNASSIGN_USER_TO_PROJECT, "Project and user has UPSA type!");
fail().withError(
UNABLE_ASSIGN_UNASSIGN_USER_TO_PROJECT,
"Please verify user assignment to the project in EPAM internal system: delivery.epam.com"
);
}
if (!ProjectUtils.doesHaveUser(project, userForUnassign.getLogin())) {
fail().withError(USER_NOT_FOUND, userForUnassign.getLogin(),
Expand Down Expand Up @@ -512,7 +518,10 @@ private void updateSenderCases(Project project, List<SenderCaseDTO> cases) {
cases.stream().distinct().map(NotificationConfigConverter.TO_CASE_MODEL)
.peek(sc -> sc.setProject(project)).collect(toSet());
if (cases.size() != withoutDuplicateCases.size()) {
fail().withError(BAD_REQUEST_ERROR, "Project notification settings contain duplicate cases for this communication channel");
fail().withError(
BAD_REQUEST_ERROR,
"Project notification settings contain duplicate cases for this communication channel"
);
}

project.getSenderCases().addAll(withoutDuplicateCases);
Expand Down
Loading