chore: Refactoring for entity validation (#29176)
This commit is contained in:
parent
666493fab9
commit
d07f02b359
|
|
@ -47,11 +47,6 @@ public class ActionCollectionRefactoringServiceCEImpl implements EntityRefactori
|
|||
return REFACTOR_JSOBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> validateName(String name) {
|
||||
return Mono.just(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> refactorReferencesInExistingEntities(
|
||||
RefactorEntityNameDTO refactorEntityNameDTO, RefactoringMetaDTO refactoringMetaDTO) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.appsmith.server.controllers;
|
|||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.constants.Url;
|
||||
import com.appsmith.server.controllers.ce.ActionCollectionControllerCE;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.LayoutCollectionService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -15,7 +15,7 @@ public class ActionCollectionController extends ActionCollectionControllerCE {
|
|||
public ActionCollectionController(
|
||||
ActionCollectionService actionCollectionService,
|
||||
LayoutCollectionService layoutCollectionService,
|
||||
RefactoringSolution refactoringSolution) {
|
||||
super(actionCollectionService, layoutCollectionService, refactoringSolution);
|
||||
RefactoringService refactoringService) {
|
||||
super(actionCollectionService, layoutCollectionService, refactoringService);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.appsmith.server.constants.Url;
|
|||
import com.appsmith.server.controllers.ce.ActionControllerCE;
|
||||
import com.appsmith.server.helpers.OtlpTelemetry;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.LayoutActionService;
|
||||
import com.appsmith.server.solutions.ActionExecutionSolution;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -19,10 +19,10 @@ public class ActionController extends ActionControllerCE {
|
|||
public ActionController(
|
||||
LayoutActionService layoutActionService,
|
||||
NewActionService newActionService,
|
||||
RefactoringSolution refactoringSolution,
|
||||
RefactoringService refactoringService,
|
||||
ActionExecutionSolution actionExecutionSolution,
|
||||
OtlpTelemetry otlpTelemetry) {
|
||||
|
||||
super(layoutActionService, newActionService, refactoringSolution, actionExecutionSolution, otlpTelemetry);
|
||||
super(layoutActionService, newActionService, refactoringService, actionExecutionSolution, otlpTelemetry);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.appsmith.server.controllers;
|
|||
import com.appsmith.server.constants.Url;
|
||||
import com.appsmith.server.controllers.ce.LayoutControllerCE;
|
||||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.LayoutService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -17,7 +17,7 @@ public class LayoutController extends LayoutControllerCE {
|
|||
public LayoutController(
|
||||
LayoutService layoutService,
|
||||
UpdateLayoutService updateLayoutService,
|
||||
RefactoringSolution refactoringSolution) {
|
||||
super(layoutService, updateLayoutService, refactoringSolution);
|
||||
RefactoringService refactoringService) {
|
||||
super(layoutService, updateLayoutService, refactoringService);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.appsmith.server.dtos.EntityType;
|
|||
import com.appsmith.server.dtos.LayoutDTO;
|
||||
import com.appsmith.server.dtos.RefactorEntityNameDTO;
|
||||
import com.appsmith.server.dtos.ResponseDTO;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.LayoutCollectionService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
@ -38,16 +38,16 @@ import java.util.List;
|
|||
public class ActionCollectionControllerCE {
|
||||
private final ActionCollectionService actionCollectionService;
|
||||
private final LayoutCollectionService layoutCollectionService;
|
||||
private final RefactoringSolution refactoringSolution;
|
||||
private final RefactoringService refactoringService;
|
||||
|
||||
@Autowired
|
||||
public ActionCollectionControllerCE(
|
||||
ActionCollectionService actionCollectionService,
|
||||
LayoutCollectionService layoutCollectionService,
|
||||
RefactoringSolution refactoringSolution) {
|
||||
RefactoringService refactoringService) {
|
||||
this.actionCollectionService = actionCollectionService;
|
||||
this.layoutCollectionService = layoutCollectionService;
|
||||
this.refactoringSolution = refactoringSolution;
|
||||
this.refactoringService = refactoringService;
|
||||
}
|
||||
|
||||
@JsonView(Views.Public.class)
|
||||
|
|
@ -98,7 +98,7 @@ public class ActionCollectionControllerCE {
|
|||
@RequestBody RefactorEntityNameDTO refactorEntityNameDTO,
|
||||
@RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) {
|
||||
refactorEntityNameDTO.setEntityType(EntityType.JS_OBJECT);
|
||||
return refactoringSolution
|
||||
return refactoringService
|
||||
.refactorEntityName(refactorEntityNameDTO, branchName)
|
||||
.map(created -> new ResponseDTO<>(HttpStatus.OK.value(), created, null));
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ public class ActionCollectionControllerCE {
|
|||
refactorEntityNameDTO.getActionCollection().getId());
|
||||
|
||||
refactorEntityNameDTO.setEntityType(EntityType.JS_ACTION);
|
||||
return refactoringSolution
|
||||
return refactoringService
|
||||
.refactorEntityName(refactorEntityNameDTO, branchName)
|
||||
.map(updatedResource -> new ResponseDTO<>(HttpStatus.OK.value(), updatedResource, null));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.appsmith.server.dtos.RefactorEntityNameDTO;
|
|||
import com.appsmith.server.dtos.ResponseDTO;
|
||||
import com.appsmith.server.helpers.OtlpTelemetry;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.LayoutActionService;
|
||||
import com.appsmith.server.solutions.ActionExecutionSolution;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
|
|
@ -47,7 +47,7 @@ public class ActionControllerCE {
|
|||
|
||||
private final LayoutActionService layoutActionService;
|
||||
private final NewActionService newActionService;
|
||||
private final RefactoringSolution refactoringSolution;
|
||||
private final RefactoringService refactoringService;
|
||||
private final ActionExecutionSolution actionExecutionSolution;
|
||||
private final OtlpTelemetry otlpTelemetry;
|
||||
|
||||
|
|
@ -55,12 +55,12 @@ public class ActionControllerCE {
|
|||
public ActionControllerCE(
|
||||
LayoutActionService layoutActionService,
|
||||
NewActionService newActionService,
|
||||
RefactoringSolution refactoringSolution,
|
||||
RefactoringService refactoringService,
|
||||
ActionExecutionSolution actionExecutionSolution,
|
||||
OtlpTelemetry otlpTelemetry) {
|
||||
this.layoutActionService = layoutActionService;
|
||||
this.newActionService = newActionService;
|
||||
this.refactoringSolution = refactoringSolution;
|
||||
this.refactoringService = refactoringService;
|
||||
this.actionExecutionSolution = actionExecutionSolution;
|
||||
this.otlpTelemetry = otlpTelemetry;
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ public class ActionControllerCE {
|
|||
@RequestBody RefactorEntityNameDTO refactorEntityNameDTO,
|
||||
@RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) {
|
||||
refactorEntityNameDTO.setEntityType(EntityType.ACTION);
|
||||
return refactoringSolution
|
||||
return refactoringService
|
||||
.refactorEntityName(refactorEntityNameDTO, branchName)
|
||||
.map(created -> new ResponseDTO<>(HttpStatus.OK.value(), created, null));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.appsmith.server.dtos.RefactorEntityNameDTO;
|
|||
import com.appsmith.server.dtos.ResponseDTO;
|
||||
import com.appsmith.server.dtos.UpdateMultiplePageLayoutDTO;
|
||||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.LayoutService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
@ -33,16 +33,16 @@ public class LayoutControllerCE {
|
|||
|
||||
private final LayoutService service;
|
||||
private final UpdateLayoutService updateLayoutService;
|
||||
private final RefactoringSolution refactoringSolution;
|
||||
private final RefactoringService refactoringService;
|
||||
|
||||
@Autowired
|
||||
public LayoutControllerCE(
|
||||
LayoutService layoutService,
|
||||
UpdateLayoutService updateLayoutService,
|
||||
RefactoringSolution refactoringSolution) {
|
||||
RefactoringService refactoringService) {
|
||||
this.service = layoutService;
|
||||
this.updateLayoutService = updateLayoutService;
|
||||
this.refactoringSolution = refactoringSolution;
|
||||
this.refactoringService = refactoringService;
|
||||
}
|
||||
|
||||
@JsonView(Views.Public.class)
|
||||
|
|
@ -107,7 +107,7 @@ public class LayoutControllerCE {
|
|||
@RequestBody RefactorEntityNameDTO refactorEntityNameDTO,
|
||||
@RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) {
|
||||
refactorEntityNameDTO.setEntityType(EntityType.WIDGET);
|
||||
return refactoringSolution
|
||||
return refactoringService
|
||||
.refactorEntityName(refactorEntityNameDTO, branchName)
|
||||
.map(created -> new ResponseDTO<>(HttpStatus.OK.value(), created, null));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,7 @@ public class RefactorEntityNameCE_DTO {
|
|||
|
||||
@JsonView(Views.Internal.class)
|
||||
String newFullyQualifiedName;
|
||||
|
||||
@JsonView(Views.Internal.class)
|
||||
Boolean isInternal;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ import java.util.Set;
|
|||
|
||||
public interface NewActionServiceCE extends CrudService<NewAction, String> {
|
||||
|
||||
Boolean validateActionName(String name);
|
||||
|
||||
void setCommonFieldsFromActionDTOIntoNewAction(ActionDTO action, NewAction newAction);
|
||||
|
||||
Mono<ActionDTO> generateActionByViewMode(NewAction newAction, Boolean viewMode);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import com.appsmith.server.solutions.ApplicationPermission;
|
|||
import com.appsmith.server.solutions.DatasourcePermission;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.appsmith.server.solutions.PolicySolution;
|
||||
import com.appsmith.server.validations.EntityValidationService;
|
||||
import com.mongodb.bulk.BulkWriteResult;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
import jakarta.validation.Validator;
|
||||
|
|
@ -74,7 +75,6 @@ import reactor.core.publisher.Mono;
|
|||
import reactor.core.scheduler.Scheduler;
|
||||
import reactor.util.function.Tuple2;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -127,6 +127,7 @@ public class NewActionServiceCEImpl extends BaseService<NewActionRepository, New
|
|||
private final ApplicationPermission applicationPermission;
|
||||
private final PagePermission pagePermission;
|
||||
protected final ActionPermission actionPermission;
|
||||
private final EntityValidationService entityValidationService;
|
||||
|
||||
private final ObservationRegistry observationRegistry;
|
||||
private final Map<String, Plugin> defaultPluginMap = new HashMap<>();
|
||||
|
|
@ -154,6 +155,7 @@ public class NewActionServiceCEImpl extends BaseService<NewActionRepository, New
|
|||
ApplicationPermission applicationPermission,
|
||||
PagePermission pagePermission,
|
||||
ActionPermission actionPermission,
|
||||
EntityValidationService entityValidationService,
|
||||
ObservationRegistry observationRegistry) {
|
||||
|
||||
super(scheduler, validator, mongoConverter, reactiveMongoTemplate, repository, analyticsService);
|
||||
|
|
@ -167,6 +169,7 @@ public class NewActionServiceCEImpl extends BaseService<NewActionRepository, New
|
|||
this.applicationService = applicationService;
|
||||
this.policySolution = policySolution;
|
||||
this.permissionGroupService = permissionGroupService;
|
||||
this.entityValidationService = entityValidationService;
|
||||
this.observationRegistry = observationRegistry;
|
||||
this.responseUtils = responseUtils;
|
||||
this.configService = configService;
|
||||
|
|
@ -176,14 +179,6 @@ public class NewActionServiceCEImpl extends BaseService<NewActionRepository, New
|
|||
this.actionPermission = actionPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean validateActionName(String name) {
|
||||
boolean isValidName = SourceVersion.isName(name);
|
||||
String pattern = "^((?=[A-Za-z0-9_])(?![\\\\-]).)*$";
|
||||
boolean doesPatternMatch = name.matches(pattern);
|
||||
return (isValidName && doesPatternMatch);
|
||||
}
|
||||
|
||||
private void setCommonFieldsFromNewActionIntoAction(NewAction newAction, ActionDTO action) {
|
||||
|
||||
// Set the fields from NewAction into Action
|
||||
|
|
@ -292,7 +287,7 @@ public class NewActionServiceCEImpl extends BaseService<NewActionRepository, New
|
|||
|
||||
this.validateCreatorId(action);
|
||||
|
||||
if (!validateActionName(action.getName())) {
|
||||
if (!entityValidationService.validateName(action.getName())) {
|
||||
action.setIsValid(false);
|
||||
invalids.add(AppsmithError.INVALID_ACTION_NAME.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.appsmith.server.solutions.ApplicationPermission;
|
|||
import com.appsmith.server.solutions.DatasourcePermission;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.appsmith.server.solutions.PolicySolution;
|
||||
import com.appsmith.server.validations.EntityValidationService;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -51,6 +52,7 @@ public class NewActionServiceImpl extends NewActionServiceCEImpl implements NewA
|
|||
ApplicationPermission applicationPermission,
|
||||
PagePermission pagePermission,
|
||||
ActionPermission actionPermission,
|
||||
EntityValidationService entityValidationService,
|
||||
ObservationRegistry observationRegistry) {
|
||||
|
||||
super(
|
||||
|
|
@ -75,6 +77,7 @@ public class NewActionServiceImpl extends NewActionServiceCEImpl implements NewA
|
|||
applicationPermission,
|
||||
pagePermission,
|
||||
actionPermission,
|
||||
entityValidationService,
|
||||
observationRegistry);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,11 +43,6 @@ public class JsActionRefactoringServiceCEImpl implements EntityRefactoringServic
|
|||
RefactoringUtils.updateFQNUsingCollectionName(refactorEntityNameDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> validateName(String name) {
|
||||
return Mono.just(newActionService.validateActionName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> refactorReferencesInExistingEntities(
|
||||
RefactorEntityNameDTO refactorEntityNameDTO, RefactoringMetaDTO refactoringMetaDTO) {
|
||||
|
|
|
|||
|
|
@ -55,11 +55,6 @@ public class NewActionRefactoringServiceCEImpl implements EntityRefactoringServi
|
|||
RefactoringUtils.updateFQNUsingCollectionName(refactorEntityNameDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> validateName(String name) {
|
||||
return Mono.just(newActionService.validateActionName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> refactorReferencesInExistingEntities(
|
||||
RefactorEntityNameDTO refactorEntityNameDTO, RefactoringMetaDTO refactoringMetaDTO) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
package com.appsmith.server.refactors.applications;
|
||||
|
||||
public interface RefactoringService extends RefactoringServiceCE {}
|
||||
|
|
@ -7,7 +7,7 @@ import reactor.core.publisher.Mono;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
public interface RefactoringSolutionCE {
|
||||
public interface RefactoringServiceCE {
|
||||
|
||||
Mono<LayoutDTO> refactorEntityName(RefactorEntityNameDTO refactorEntityNameDTO, String branchName);
|
||||
|
||||
|
|
@ -20,6 +20,7 @@ import com.appsmith.server.services.AnalyticsService;
|
|||
import com.appsmith.server.services.ApplicationService;
|
||||
import com.appsmith.server.services.SessionUserService;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.appsmith.server.validations.EntityValidationService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
|
|
@ -40,7 +41,7 @@ import static com.appsmith.server.services.ce.ApplicationPageServiceCEImpl.EVALU
|
|||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class RefactoringSolutionCEImpl implements RefactoringSolutionCE {
|
||||
public class RefactoringServiceCEImpl implements RefactoringServiceCE {
|
||||
private final NewPageService newPageService;
|
||||
private final ResponseUtils responseUtils;
|
||||
private final UpdateLayoutService updateLayoutService;
|
||||
|
|
@ -49,6 +50,7 @@ public class RefactoringSolutionCEImpl implements RefactoringSolutionCE {
|
|||
private final AnalyticsService analyticsService;
|
||||
private final SessionUserService sessionUserService;
|
||||
private final TransactionalOperator transactionalOperator;
|
||||
private final EntityValidationService entityValidationService;
|
||||
|
||||
protected final EntityRefactoringService<Void> jsActionEntityRefactoringService;
|
||||
protected final EntityRefactoringService<NewAction> newActionEntityRefactoringService;
|
||||
|
|
@ -151,7 +153,8 @@ public class RefactoringSolutionCEImpl implements RefactoringSolutionCE {
|
|||
service.sanitizeRefactorEntityDTO(refactorEntityNameDTO);
|
||||
|
||||
// Validate whether this name is allowed based on the type of entity
|
||||
Mono<Boolean> isValidNameMono = service.validateName(refactorEntityNameDTO.getNewName())
|
||||
Mono<Boolean> isValidNameMono = Mono.just(
|
||||
entityValidationService.validateName(refactorEntityNameDTO.getNewName()))
|
||||
.flatMap(isValid -> {
|
||||
if (!isValid) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_ACTION_NAME));
|
||||
|
|
@ -11,15 +11,16 @@ import com.appsmith.server.services.AnalyticsService;
|
|||
import com.appsmith.server.services.ApplicationService;
|
||||
import com.appsmith.server.services.SessionUserService;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.appsmith.server.validations.EntityValidationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RefactoringSolutionImpl extends RefactoringSolutionCEImpl implements RefactoringSolution {
|
||||
public class RefactoringServiceImpl extends RefactoringServiceCEImpl implements RefactoringService {
|
||||
|
||||
public RefactoringSolutionImpl(
|
||||
public RefactoringServiceImpl(
|
||||
NewPageService newPageService,
|
||||
ResponseUtils responseUtils,
|
||||
UpdateLayoutService updateLayoutService,
|
||||
|
|
@ -28,6 +29,7 @@ public class RefactoringSolutionImpl extends RefactoringSolutionCEImpl implement
|
|||
AnalyticsService analyticsService,
|
||||
SessionUserService sessionUserService,
|
||||
TransactionalOperator transactionalOperator,
|
||||
EntityValidationService entityValidationService,
|
||||
EntityRefactoringService<Void> jsActionEntityRefactoringService,
|
||||
EntityRefactoringService<NewAction> newActionEntityRefactoringService,
|
||||
EntityRefactoringService<ActionCollection> actionCollectionEntityRefactoringService,
|
||||
|
|
@ -41,6 +43,7 @@ public class RefactoringSolutionImpl extends RefactoringSolutionCEImpl implement
|
|||
analyticsService,
|
||||
sessionUserService,
|
||||
transactionalOperator,
|
||||
entityValidationService,
|
||||
jsActionEntityRefactoringService,
|
||||
newActionEntityRefactoringService,
|
||||
actionCollectionEntityRefactoringService,
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
package com.appsmith.server.refactors.applications;
|
||||
|
||||
public interface RefactoringSolution extends RefactoringSolutionCE {}
|
||||
|
|
@ -17,8 +17,6 @@ public interface EntityRefactoringServiceCE<T> {
|
|||
refactorEntityNameDTO.setNewFullyQualifiedName(refactorEntityNameDTO.getNewName());
|
||||
}
|
||||
|
||||
Mono<Boolean> validateName(String newName);
|
||||
|
||||
Mono<Void> refactorReferencesInExistingEntities(
|
||||
RefactorEntityNameDTO refactorEntityNameDTO, RefactoringMetaDTO refactoringMetaDTO);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.appsmith.server.helpers.ResponseUtils;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.ce.LayoutActionServiceCEImpl;
|
||||
import com.appsmith.server.solutions.ActionPermission;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
|
|
@ -20,7 +20,7 @@ public class LayoutActionServiceImpl extends LayoutActionServiceCEImpl implement
|
|||
AnalyticsService analyticsService,
|
||||
NewPageService newPageService,
|
||||
NewActionService newActionService,
|
||||
RefactoringSolution refactoringSolution,
|
||||
RefactoringService refactoringService,
|
||||
CollectionService collectionService,
|
||||
UpdateLayoutService updateLayoutService,
|
||||
ResponseUtils responseUtils,
|
||||
|
|
@ -31,7 +31,7 @@ public class LayoutActionServiceImpl extends LayoutActionServiceCEImpl implement
|
|||
analyticsService,
|
||||
newPageService,
|
||||
newActionService,
|
||||
refactoringSolution,
|
||||
refactoringService,
|
||||
collectionService,
|
||||
updateLayoutService,
|
||||
responseUtils,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.appsmith.server.helpers.ResponseUtils;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.ActionCollectionRepository;
|
||||
import com.appsmith.server.services.ce.LayoutCollectionServiceCEImpl;
|
||||
import com.appsmith.server.solutions.ActionPermission;
|
||||
|
|
@ -21,7 +21,7 @@ public class LayoutCollectionServiceImpl extends LayoutCollectionServiceCEImpl i
|
|||
NewPageService newPageService,
|
||||
LayoutActionService layoutActionService,
|
||||
UpdateLayoutService updateLayoutService,
|
||||
RefactoringSolution refactoringSolution,
|
||||
RefactoringService refactoringService,
|
||||
ActionCollectionService actionCollectionService,
|
||||
NewActionService newActionService,
|
||||
AnalyticsService analyticsService,
|
||||
|
|
@ -33,7 +33,7 @@ public class LayoutCollectionServiceImpl extends LayoutCollectionServiceCEImpl i
|
|||
newPageService,
|
||||
layoutActionService,
|
||||
updateLayoutService,
|
||||
refactoringSolution,
|
||||
refactoringService,
|
||||
actionCollectionService,
|
||||
newActionService,
|
||||
analyticsService,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.appsmith.server.helpers.ResponseUtils;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.services.AnalyticsService;
|
||||
import com.appsmith.server.services.CollectionService;
|
||||
import com.appsmith.server.solutions.ActionPermission;
|
||||
|
|
@ -44,7 +44,7 @@ public class LayoutActionServiceCEImpl implements LayoutActionServiceCE {
|
|||
private final AnalyticsService analyticsService;
|
||||
private final NewPageService newPageService;
|
||||
private final NewActionService newActionService;
|
||||
private final RefactoringSolution refactoringSolution;
|
||||
private final RefactoringService refactoringService;
|
||||
private final CollectionService collectionService;
|
||||
private final UpdateLayoutService updateLayoutService;
|
||||
private final ResponseUtils responseUtils;
|
||||
|
|
@ -396,7 +396,7 @@ public class LayoutActionServiceCEImpl implements LayoutActionServiceCE {
|
|||
String name = action.getValidName();
|
||||
CreatorContextType contextType =
|
||||
action.getContextType() == null ? CreatorContextType.PAGE : action.getContextType();
|
||||
return refactoringSolution.isNameAllowed(page.getId(), contextType, layout.getId(), name);
|
||||
return refactoringService.isNameAllowed(page.getId(), contextType, layout.getId(), name);
|
||||
})
|
||||
.flatMap(nameAllowed -> {
|
||||
// If the name is allowed, return pageMono for further processing
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import com.appsmith.server.helpers.ResponseUtils;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.ActionCollectionRepository;
|
||||
import com.appsmith.server.services.AnalyticsService;
|
||||
import com.appsmith.server.services.LayoutActionService;
|
||||
|
|
@ -52,7 +52,7 @@ public class LayoutCollectionServiceCEImpl implements LayoutCollectionServiceCE
|
|||
private final NewPageService newPageService;
|
||||
private final LayoutActionService layoutActionService;
|
||||
private final UpdateLayoutService updateLayoutService;
|
||||
private final RefactoringSolution refactoringSolution;
|
||||
private final RefactoringService refactoringService;
|
||||
private final ActionCollectionService actionCollectionService;
|
||||
private final NewActionService newActionService;
|
||||
private final AnalyticsService analyticsService;
|
||||
|
|
@ -96,7 +96,7 @@ public class LayoutCollectionServiceCEImpl implements LayoutCollectionServiceCE
|
|||
CreatorContextType contextType =
|
||||
collection.getContextType() == null ? CreatorContextType.PAGE : collection.getContextType();
|
||||
// Check against widget names and action names
|
||||
return refactoringSolution.isNameAllowed(
|
||||
return refactoringService.isNameAllowed(
|
||||
page.getId(), contextType, layout.getId(), collection.getName());
|
||||
})
|
||||
.flatMap(isNameAllowed -> {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
package com.appsmith.server.validations;
|
||||
|
||||
public interface EntityValidationService extends EntityValidationServiceCE {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.appsmith.server.validations;
|
||||
|
||||
public interface EntityValidationServiceCE {
|
||||
|
||||
boolean validateName(String name, Boolean isInternal);
|
||||
|
||||
default boolean validateName(String name) {
|
||||
return this.validateName(name, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.appsmith.server.validations;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
@Service
|
||||
public class EntityValidationServiceCEImpl implements EntityValidationServiceCE {
|
||||
|
||||
@Override
|
||||
public boolean validateName(String name, Boolean isInternal) {
|
||||
String pattern = "^((?=[A-Za-z0-9_])(?![\\\\-]).)*$";
|
||||
return this.validateNameWithPattern(name, pattern);
|
||||
}
|
||||
|
||||
protected boolean validateNameWithPattern(String name, String pattern) {
|
||||
boolean isValidName = SourceVersion.isName(name);
|
||||
boolean doesPatternMatch = name.matches(pattern);
|
||||
return isValidName && doesPatternMatch;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.appsmith.server.validations;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class EntityValidationServiceImpl extends EntityValidationServiceCEImpl implements EntityValidationService {}
|
||||
|
|
@ -53,11 +53,6 @@ public class WidgetRefactoringServiceCEImpl implements EntityRefactoringServiceC
|
|||
return REFACTOR_WIDGET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> validateName(String name) {
|
||||
return Mono.just(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> refactorReferencesInExistingEntities(
|
||||
RefactorEntityNameDTO refactorEntityNameDTO, RefactoringMetaDTO refactoringMetaDTO) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import com.appsmith.server.imports.internal.ImportApplicationService;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.NewActionRepository;
|
||||
import com.appsmith.server.repositories.PluginRepository;
|
||||
import com.appsmith.server.services.ApplicationPageService;
|
||||
|
|
@ -86,7 +86,7 @@ public class RefactoringSolutionTest {
|
|||
UpdateLayoutService updateLayoutService;
|
||||
|
||||
@Autowired
|
||||
RefactoringSolution refactoringSolution;
|
||||
RefactoringService refactoringService;
|
||||
|
||||
@Autowired
|
||||
LayoutCollectionService layoutCollectionService;
|
||||
|
|
@ -249,7 +249,7 @@ public class RefactoringSolutionTest {
|
|||
Mockito.when(actionCollectionService.getActionCollectionsByViewMode(Mockito.any(), Mockito.anyBoolean()))
|
||||
.thenReturn(Flux.just(mockActionCollectionDTO));
|
||||
|
||||
Mono<Boolean> nameAllowedMono = refactoringSolution.isNameAllowed(
|
||||
Mono<Boolean> nameAllowedMono = refactoringService.isNameAllowed(
|
||||
testPage.getId(),
|
||||
CreatorContextType.PAGE,
|
||||
testPage.getLayouts().get(0).getId(),
|
||||
|
|
@ -284,7 +284,7 @@ public class RefactoringSolutionTest {
|
|||
Mockito.when(actionCollectionService.getActionCollectionsByViewMode(Mockito.any(), Mockito.anyBoolean()))
|
||||
.thenReturn(Flux.just(mockActionCollectionDTO));
|
||||
|
||||
Mono<Boolean> nameAllowedMono = refactoringSolution.isNameAllowed(
|
||||
Mono<Boolean> nameAllowedMono = refactoringService.isNameAllowed(
|
||||
testPage.getId(),
|
||||
CreatorContextType.PAGE,
|
||||
testPage.getLayouts().get(0).getId(),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.appsmith.server.helpers.ResponseUtils;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.ActionCollectionRepository;
|
||||
import com.appsmith.server.solutions.ActionPermission;
|
||||
import com.appsmith.server.solutions.ActionPermissionImpl;
|
||||
|
|
@ -87,7 +87,7 @@ public class ActionCollectionServiceImplTest {
|
|||
UpdateLayoutService updateLayoutService;
|
||||
|
||||
@MockBean
|
||||
RefactoringSolution refactoringSolution;
|
||||
RefactoringService refactoringService;
|
||||
|
||||
@MockBean
|
||||
ActionCollectionRepository actionCollectionRepository;
|
||||
|
|
@ -146,7 +146,7 @@ public class ActionCollectionServiceImplTest {
|
|||
newPageService,
|
||||
layoutActionService,
|
||||
updateLayoutService,
|
||||
refactoringSolution,
|
||||
refactoringService,
|
||||
actionCollectionService,
|
||||
newActionService,
|
||||
analyticsService,
|
||||
|
|
@ -234,7 +234,7 @@ public class ActionCollectionServiceImplTest {
|
|||
final NewPage newPage = objectMapper.convertValue(jsonNode.get("newPage"), NewPage.class);
|
||||
Mockito.when(newPageService.findById(Mockito.any(), Mockito.<AclPermission>any()))
|
||||
.thenReturn(Mono.just(newPage));
|
||||
Mockito.when(refactoringSolution.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
|
||||
Mockito.when(refactoringService.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(Mono.just(false));
|
||||
|
||||
Mockito.when(actionCollectionRepository.findAllActionCollectionsByNamePageIdsViewModeAndBranch(
|
||||
|
|
@ -275,7 +275,7 @@ public class ActionCollectionServiceImplTest {
|
|||
|
||||
Mockito.when(newPageService.findById(Mockito.any(), Mockito.<AclPermission>any()))
|
||||
.thenReturn(Mono.just(newPage));
|
||||
Mockito.when(refactoringSolution.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
|
||||
Mockito.when(refactoringService.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(Mono.just(true));
|
||||
|
||||
Mockito.when(actionCollectionRepository.findAllActionCollectionsByNamePageIdsViewModeAndBranch(
|
||||
|
|
@ -340,7 +340,7 @@ public class ActionCollectionServiceImplTest {
|
|||
|
||||
Mockito.when(newPageService.findById(Mockito.any(), Mockito.<AclPermission>any()))
|
||||
.thenReturn(Mono.just(newPage));
|
||||
Mockito.when(refactoringSolution.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
|
||||
Mockito.when(refactoringService.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(Mono.just(true));
|
||||
|
||||
Mockito.when(actionCollectionRepository.findAllActionCollectionsByNamePageIdsViewModeAndBranch(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.appsmith.server.helpers.PluginExecutorHelper;
|
|||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.plugins.base.PluginService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.ActionCollectionRepository;
|
||||
import com.appsmith.server.repositories.PermissionGroupRepository;
|
||||
import com.appsmith.server.repositories.PluginRepository;
|
||||
|
|
@ -91,7 +91,7 @@ public class ActionCollectionServiceTest {
|
|||
LayoutActionService layoutActionService;
|
||||
|
||||
@Autowired
|
||||
RefactoringSolution refactoringSolution;
|
||||
RefactoringService refactoringService;
|
||||
|
||||
@Autowired
|
||||
NewPageService newPageService;
|
||||
|
|
@ -411,7 +411,7 @@ public class ActionCollectionServiceTest {
|
|||
refactorActionNameDTO.setOldName("testAction1");
|
||||
refactorActionNameDTO.setNewName("newTestAction1");
|
||||
|
||||
final LayoutDTO layoutDTO = refactoringSolution
|
||||
final LayoutDTO layoutDTO = refactoringService
|
||||
.refactorEntityName(refactorActionNameDTO, null)
|
||||
.block();
|
||||
|
||||
|
|
@ -503,7 +503,7 @@ public class ActionCollectionServiceTest {
|
|||
refactorActionNameDTO.setOldName("run");
|
||||
refactorActionNameDTO.setNewName("newRun");
|
||||
|
||||
final LayoutDTO layoutDTO = refactoringSolution
|
||||
final LayoutDTO layoutDTO = refactoringService
|
||||
.refactorEntityName(refactorActionNameDTO, null)
|
||||
.block();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import com.appsmith.server.imports.internal.ImportApplicationService;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.NewActionRepository;
|
||||
import com.appsmith.server.repositories.PluginRepository;
|
||||
import com.appsmith.server.solutions.ApplicationPermission;
|
||||
|
|
@ -109,7 +109,7 @@ public class LayoutActionServiceTest {
|
|||
UpdateLayoutService updateLayoutService;
|
||||
|
||||
@Autowired
|
||||
RefactoringSolution refactoringSolution;
|
||||
RefactoringService refactoringService;
|
||||
|
||||
@Autowired
|
||||
LayoutCollectionService layoutCollectionService;
|
||||
|
|
@ -1288,7 +1288,7 @@ public class LayoutActionServiceTest {
|
|||
refactorActionNameDTO.setPageId(testPage.getId());
|
||||
refactorActionNameDTO.setActionId(createdAction.getId());
|
||||
|
||||
Mono<LayoutDTO> layoutDTOMono = refactoringSolution.refactorEntityName(refactorActionNameDTO, null);
|
||||
Mono<LayoutDTO> layoutDTOMono = refactoringService.refactorEntityName(refactorActionNameDTO, null);
|
||||
StepVerifier.create(layoutDTOMono.map(
|
||||
layoutDTO -> layoutDTO.getLayoutOnLoadActionErrors().size()))
|
||||
.expectNext(1)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.appsmith.server.solutions.ApplicationPermission;
|
|||
import com.appsmith.server.solutions.DatasourcePermission;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.appsmith.server.solutions.PolicySolution;
|
||||
import com.appsmith.server.validations.EntityValidationService;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -110,6 +111,9 @@ public class NewActionServiceUnitTest {
|
|||
@MockBean
|
||||
PagePermission pagePermission;
|
||||
|
||||
@MockBean
|
||||
EntityValidationService entityValidationService;
|
||||
|
||||
ActionPermission actionPermission = new ActionPermissionImpl();
|
||||
|
||||
@MockBean
|
||||
|
|
@ -139,11 +143,13 @@ public class NewActionServiceUnitTest {
|
|||
applicationPermission,
|
||||
pagePermission,
|
||||
actionPermission,
|
||||
entityValidationService,
|
||||
observationRegistry);
|
||||
|
||||
ObservationRegistry.ObservationConfig mockObservationConfig =
|
||||
Mockito.mock(ObservationRegistry.ObservationConfig.class);
|
||||
Mockito.when(observationRegistry.observationConfig()).thenReturn(mockObservationConfig);
|
||||
Mockito.doReturn(true).when(entityValidationService).validateName(Mockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import com.appsmith.server.helpers.ResponseUtils;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolutionCEImpl;
|
||||
import com.appsmith.server.refactors.applications.RefactoringServiceCEImpl;
|
||||
import com.appsmith.server.refactors.entities.EntityRefactoringService;
|
||||
import com.appsmith.server.repositories.ActionCollectionRepository;
|
||||
import com.appsmith.server.services.AnalyticsService;
|
||||
|
|
@ -27,6 +27,7 @@ import com.appsmith.server.services.ApplicationService;
|
|||
import com.appsmith.server.services.SessionUserService;
|
||||
import com.appsmith.server.solutions.ActionPermission;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.appsmith.server.validations.EntityValidationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
@ -54,8 +55,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
@ExtendWith(SpringExtension.class)
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
class RefactoringSolutionCEImplTest {
|
||||
RefactoringSolutionCEImpl refactoringSolutionCE;
|
||||
class RefactoringServiceCEImplTest {
|
||||
RefactoringServiceCEImpl refactoringServiceCE;
|
||||
|
||||
@Autowired
|
||||
PagePermission pagePermission;
|
||||
|
|
@ -102,12 +103,15 @@ class RefactoringSolutionCEImplTest {
|
|||
@Autowired
|
||||
private TransactionalOperator transactionalOperator;
|
||||
|
||||
@Autowired
|
||||
private EntityValidationService entityValidationService;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
|
||||
Mockito.when(sessionUserService.getCurrentUser()).thenReturn(Mono.just(new User()));
|
||||
|
||||
refactoringSolutionCE = new RefactoringSolutionCEImpl(
|
||||
refactoringServiceCE = new RefactoringServiceCEImpl(
|
||||
newPageService,
|
||||
responseUtils,
|
||||
updateLayoutService,
|
||||
|
|
@ -116,6 +120,7 @@ class RefactoringSolutionCEImplTest {
|
|||
analyticsService,
|
||||
sessionUserService,
|
||||
transactionalOperator,
|
||||
entityValidationService,
|
||||
jsActionEntityRefactoringService,
|
||||
newActionEntityRefactoringService,
|
||||
actionCollectionEntityRefactoringService,
|
||||
|
|
@ -188,7 +193,7 @@ class RefactoringSolutionCEImplTest {
|
|||
.getExistingEntityNames(Mockito.anyString(), Mockito.any(), Mockito.anyString());
|
||||
|
||||
final Mono<LayoutDTO> layoutDTOMono =
|
||||
refactoringSolutionCE.refactorEntityName(refactorActionCollectionNameDTO, null);
|
||||
refactoringServiceCE.refactorEntityName(refactorActionCollectionNameDTO, null);
|
||||
|
||||
StepVerifier.create(layoutDTOMono)
|
||||
.assertNext(layoutDTO -> {
|
||||
|
|
@ -241,7 +246,7 @@ class RefactoringSolutionCEImplTest {
|
|||
Mockito.when(newPageService.getById(Mockito.anyString())).thenReturn(Mono.just(newPage));
|
||||
|
||||
final Mono<LayoutDTO> layoutDTOMono =
|
||||
refactoringSolutionCE.refactorEntityName(refactorActionCollectionNameDTO, null);
|
||||
refactoringServiceCE.refactorEntityName(refactorActionCollectionNameDTO, null);
|
||||
|
||||
StepVerifier.create(layoutDTOMono)
|
||||
.expectErrorMatches(e -> AppsmithError.NAME_CLASH_NOT_ALLOWED_IN_REFACTOR
|
||||
|
|
@ -330,7 +335,7 @@ class RefactoringSolutionCEImplTest {
|
|||
.getExistingEntityNames(Mockito.anyString(), Mockito.any(), Mockito.anyString());
|
||||
|
||||
final Mono<LayoutDTO> layoutDTOMono =
|
||||
refactoringSolutionCE.refactorEntityName(refactorActionCollectionNameDTO, null);
|
||||
refactoringServiceCE.refactorEntityName(refactorActionCollectionNameDTO, null);
|
||||
|
||||
StepVerifier.create(layoutDTOMono)
|
||||
.assertNext(layoutDTO -> {
|
||||
|
|
@ -30,7 +30,7 @@ import com.appsmith.server.imports.internal.ImportApplicationService;
|
|||
import com.appsmith.server.layouts.UpdateLayoutService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringSolution;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
import com.appsmith.server.repositories.NewActionRepository;
|
||||
import com.appsmith.server.repositories.PluginRepository;
|
||||
import com.appsmith.server.services.ApplicationPageService;
|
||||
|
|
@ -79,7 +79,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
@SpringBootTest
|
||||
@Slf4j
|
||||
@DirtiesContext
|
||||
class RefactoringSolutionCETest {
|
||||
class RefactoringServiceCETest {
|
||||
|
||||
@SpyBean
|
||||
NewActionService newActionService;
|
||||
|
|
@ -106,7 +106,7 @@ class RefactoringSolutionCETest {
|
|||
UpdateLayoutService updateLayoutService;
|
||||
|
||||
@Autowired
|
||||
RefactoringSolution refactoringSolution;
|
||||
RefactoringService refactoringService;
|
||||
|
||||
@Autowired
|
||||
LayoutCollectionService layoutCollectionService;
|
||||
|
|
@ -307,7 +307,7 @@ class RefactoringSolutionCETest {
|
|||
refactorActionNameDTO.setNewName("PostNameChange");
|
||||
refactorActionNameDTO.setActionId(createdAction.getId());
|
||||
|
||||
LayoutDTO postNameChangeLayout = refactoringSolution
|
||||
LayoutDTO postNameChangeLayout = refactoringService
|
||||
.refactorEntityName(refactorActionNameDTO, null)
|
||||
.block();
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ class RefactoringSolutionCETest {
|
|||
refactorActionNameDTO.setNewName("PostNameChange");
|
||||
refactorActionNameDTO.setActionId(createdAction.getId());
|
||||
|
||||
LayoutDTO postNameChangeLayout = refactoringSolution
|
||||
LayoutDTO postNameChangeLayout = refactoringService
|
||||
.refactorEntityName(refactorActionNameDTO, null)
|
||||
.block();
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ class RefactoringSolutionCETest {
|
|||
refactorActionNameDTO.setNewName("NewActionName");
|
||||
refactorActionNameDTO.setActionId(firstAction.getId());
|
||||
|
||||
refactoringSolution.refactorEntityName(refactorActionNameDTO, null).block();
|
||||
refactoringService.refactorEntityName(refactorActionNameDTO, null).block();
|
||||
|
||||
Mono<NewAction> postNameChangeActionMono = newActionService.findById(secondAction.getId(), READ_ACTIONS);
|
||||
|
||||
|
|
@ -513,7 +513,7 @@ class RefactoringSolutionCETest {
|
|||
assert createdAction != null;
|
||||
refactorActionNameDTO.setActionId(createdAction.getId());
|
||||
|
||||
final Mono<LayoutDTO> layoutDTOMono = refactoringSolution.refactorEntityName(refactorActionNameDTO, null);
|
||||
final Mono<LayoutDTO> layoutDTOMono = refactoringService.refactorEntityName(refactorActionNameDTO, null);
|
||||
|
||||
StepVerifier.create(layoutDTOMono)
|
||||
.expectErrorMatches(e -> e instanceof AppsmithException
|
||||
|
|
@ -585,7 +585,7 @@ class RefactoringSolutionCETest {
|
|||
refactorActionNameDTO.setNewName("newName");
|
||||
refactorActionNameDTO.setActionId(firstAction.getId());
|
||||
|
||||
LayoutDTO postNameChangeLayout = refactoringSolution
|
||||
LayoutDTO postNameChangeLayout = refactoringService
|
||||
.refactorEntityName(refactorActionNameDTO, null)
|
||||
.block();
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ class RefactoringSolutionCETest {
|
|||
refactorNameDTO.setNewName("NewNameTable1");
|
||||
|
||||
Mono<LayoutDTO> widgetRenameMono =
|
||||
refactoringSolution.refactorEntityName(refactorNameDTO, null).cache();
|
||||
refactoringService.refactorEntityName(refactorNameDTO, null).cache();
|
||||
|
||||
Mono<PageDTO> pageFromRepoMono =
|
||||
widgetRenameMono.then(newPageService.findPageById(testPage.getId(), READ_PAGES, false));
|
||||
|
|
@ -688,7 +688,7 @@ class RefactoringSolutionCETest {
|
|||
refactorNameDTO.setNewName("NewNameTable1");
|
||||
|
||||
Mono<LayoutDTO> widgetRenameMono =
|
||||
refactoringSolution.refactorEntityName(refactorNameDTO, null).cache();
|
||||
refactoringService.refactorEntityName(refactorNameDTO, null).cache();
|
||||
|
||||
Mono<PageDTO> pageFromRepoMono =
|
||||
widgetRenameMono.then(newPageService.findPageById(testPage.getId(), READ_PAGES, false));
|
||||
|
|
@ -740,7 +740,7 @@ class RefactoringSolutionCETest {
|
|||
refactorNameDTO.setOldName("oldWidgetName");
|
||||
refactorNameDTO.setNewName("newWidgetName");
|
||||
|
||||
Mono<LayoutDTO> widgetRenameMono = refactoringSolution.refactorEntityName(refactorNameDTO, null);
|
||||
Mono<LayoutDTO> widgetRenameMono = refactoringService.refactorEntityName(refactorNameDTO, null);
|
||||
|
||||
StepVerifier.create(widgetRenameMono)
|
||||
.assertNext(updatedLayout -> {
|
||||
|
|
@ -801,7 +801,7 @@ class RefactoringSolutionCETest {
|
|||
refactorNameDTO.setNewName("NewNameTable1");
|
||||
|
||||
LayoutDTO updatedLayout =
|
||||
refactoringSolution.refactorEntityName(refactorNameDTO, null).block();
|
||||
refactoringService.refactorEntityName(refactorNameDTO, null).block();
|
||||
|
||||
assert createdActionCollectionDTO1 != null;
|
||||
final Mono<ActionCollection> actionCollectionMono =
|
||||
|
|
@ -873,7 +873,7 @@ class RefactoringSolutionCETest {
|
|||
refactorActionNameInCollectionDTO.setNewName("newTestAction");
|
||||
refactorActionNameInCollectionDTO.setCollectionName("originalName");
|
||||
|
||||
final Mono<Tuple2<ActionCollection, NewAction>> tuple2Mono = refactoringSolution
|
||||
final Mono<Tuple2<ActionCollection, NewAction>> tuple2Mono = refactoringService
|
||||
.refactorEntityName(refactorActionNameInCollectionDTO, null)
|
||||
.then(actionCollectionService
|
||||
.getById(dto.getId())
|
||||
Loading…
Reference in New Issue
Block a user