Skip to content

Commit

Permalink
EPMRPP-89665 || Update error message when UPSA user is assigned to UP…
Browse files Browse the repository at this point in the history
…SA project
  • Loading branch information
IvanKustau committed Apr 29, 2024
1 parent 9194d0c commit 35b8c1d
Showing 1 changed file with 25 additions and 16 deletions.
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

0 comments on commit 35b8c1d

Please sign in to comment.