Skip to content

Commit

Permalink
EPMRPP-90911 fix case-sensitive integration name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx committed Aug 23, 2024
1 parent 018911d commit 5698293
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ dependencies {
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:plugin-api:5.11.1'
} else {
implementation 'com.github.reportportal:commons-dao:bad7959'
implementation 'com.github.reportportal:commons-dao:ca2ccf5'
implementation 'com.github.reportportal:commons:d4be022'
implementation 'com.github.reportportal:plugin-api:d1c0f0e'
}
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ public EntryCreatedRS createGlobalIntegration(IntegrationRQ createRequest, Strin
);

String integrationName =
ofNullable(createRequest.getName()).map(String::toLowerCase).map(name -> {
ofNullable(createRequest.getName()).map(name -> {
validateGlobalIntegrationName(name, integrationType);
return name;
}).orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_INTEGRATION_NAME,
@@ -122,11 +122,12 @@ public EntryCreatedRS createProjectIntegration(String projectName, IntegrationRQ
this.basicIntegrationService
);

String integrationName =
ofNullable(createRequest.getName()).map(String::toLowerCase).map(name -> {
String integrationName = ofNullable(createRequest.getName())
.map(name -> {
validateProjectIntegrationName(name, integrationType, project);
return name;
}).orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_INTEGRATION_NAME,
})
.orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_INTEGRATION_NAME,
"Integration name should be not null"
));
createRequest.setName(integrationName);
@@ -151,7 +152,7 @@ public OperationCompletionRS updateGlobalIntegration(Long id, IntegrationRQ upda

IntegrationActivityResource beforeUpdate = TO_ACTIVITY_RESOURCE.apply(integration);

ofNullable(updateRequest.getName()).map(String::toLowerCase).ifPresent(name -> {
ofNullable(updateRequest.getName()).ifPresent(name -> {
if (!name.equals(integration.getName())) {
validateGlobalIntegrationName(name, integration.getType());
}
@@ -186,7 +187,7 @@ public OperationCompletionRS updateProjectIntegration(Long id, String projectNam

IntegrationActivityResource beforeUpdate = TO_ACTIVITY_RESOURCE.apply(integration);

ofNullable(updateRequest.getName()).map(String::toLowerCase).ifPresent(name -> {
ofNullable(updateRequest.getName()).ifPresent(name -> {
if (!name.equals(integration.getName())) {
validateProjectIntegrationName(name, integration.getType(), project);
}
@@ -215,7 +216,7 @@ private void validateGlobalIntegrationName(String integrationName,
BusinessRule.expect(integrationName, StringUtils::isNotBlank)
.verify(ErrorType.INCORRECT_INTEGRATION_NAME, "Integration name should be not empty");
BusinessRule.expect(
integrationRepository.existsByNameAndTypeIdAndProjectIdIsNull(integrationName,
integrationRepository.existsByNameIgnoreCaseAndTypeIdAndProjectIdIsNull(integrationName,
integrationType.getId()
), BooleanUtils::isFalse).verify(ErrorType.INTEGRATION_ALREADY_EXISTS,
Suppliers.formattedSupplier(
@@ -229,7 +230,7 @@ private void validateProjectIntegrationName(String integrationName,
IntegrationType integrationType, Project project) {
BusinessRule.expect(integrationName, StringUtils::isNotBlank)
.verify(ErrorType.INCORRECT_INTEGRATION_NAME, "Integration name should be not empty");
BusinessRule.expect(integrationRepository.existsByNameAndTypeIdAndProjectId(integrationName,
BusinessRule.expect(integrationRepository.existsByNameIgnoreCaseAndTypeIdAndProjectId(integrationName,
integrationType.getId(), project.getId()
), BooleanUtils::isFalse).verify(ErrorType.INTEGRATION_ALREADY_EXISTS,
Suppliers.formattedSupplier(

0 comments on commit 5698293

Please sign in to comment.