Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhi-nair committed Aug 1, 2024
1 parent 01bcca7 commit 2671d59
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Mono<ActionCollectionDTO> populateActionCollectionByViewMode(
Mono<ActionCollectionDTO> splitValidActionsByViewMode(
ActionCollectionDTO actionCollectionDTO, List<ActionDTO> actionsList, Boolean viewMode);

Flux<ActionCollectionDTO> getActionCollectionsByViewMode(MultiValueMap<String, String> params, Boolean viewMode);
Flux<ActionCollectionDTO> getNonComposedActionCollectionsByViewMode(
MultiValueMap<String, String> params, Boolean viewMode);

Mono<ActionCollectionDTO> update(String id, ActionCollectionDTO actionCollectionDTO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Mono<ActionCollection> findByBaseIdAndBranchName(String id, String branch
@Override
public Flux<ActionCollectionDTO> getPopulatedActionCollectionsByViewMode(
MultiValueMap<String, String> params, Boolean viewMode) {
return this.getActionCollectionsByViewMode(params, viewMode)
return this.getNonComposedActionCollectionsByViewMode(params, viewMode)
.flatMap(actionCollectionDTO -> this.populateActionCollectionByViewMode(actionCollectionDTO, viewMode));
}

Expand Down Expand Up @@ -187,15 +187,16 @@ public Flux<ActionCollectionViewDTO> getActionCollectionsForViewMode(String appl
return applicationService
.findBranchedApplicationId(branchName, applicationId, applicationPermission.getReadPermission())
.flatMapMany(branchedApplicationId -> repository
.findByApplicationIdAndViewMode(
.findNonComposedByApplicationIdAndViewMode(
branchedApplicationId, true, actionPermission.getExecutePermission())
.flatMap(this::generateActionCollectionViewDTO));
}

@Override
public Flux<ActionCollectionViewDTO> getActionCollectionsForViewMode(String branchedApplicationId) {
return repository
.findByApplicationIdAndViewMode(branchedApplicationId, true, actionPermission.getExecutePermission())
.findNonComposedByApplicationIdAndViewMode(
branchedApplicationId, true, actionPermission.getExecutePermission())
.flatMap(this::generateActionCollectionViewDTO);
}

Expand Down Expand Up @@ -235,16 +236,16 @@ protected Mono<ActionCollectionViewDTO> generateActionCollectionViewDTO(
}

@Override
public Flux<ActionCollectionDTO> getActionCollectionsByViewMode(
public Flux<ActionCollectionDTO> getNonComposedActionCollectionsByViewMode(
MultiValueMap<String, String> params, Boolean viewMode) {
if (params == null || viewMode == null) {
return Flux.empty();
}
return getActionCollectionsFromRepoByViewMode(params, viewMode)
return getNonComposedActionCollectionsFromRepoByViewMode(params, viewMode)
.flatMap(actionCollection -> generateActionCollectionByViewMode(actionCollection, viewMode));
}

protected Flux<ActionCollection> getActionCollectionsFromRepoByViewMode(
protected Flux<ActionCollection> getNonComposedActionCollectionsFromRepoByViewMode(
MultiValueMap<String, String> params, Boolean viewMode) {
if (params.getFirst(FieldName.APPLICATION_ID) != null) {
// Fetch unpublished pages because GET actions is only called during edit mode. For view mode, different
Expand All @@ -254,7 +255,7 @@ protected Flux<ActionCollection> getActionCollectionsFromRepoByViewMode(
params.getFirst(FieldName.BRANCH_NAME),
params.getFirst(FieldName.APPLICATION_ID),
applicationPermission.getReadPermission())
.flatMapMany(childApplicationId -> repository.findByApplicationIdAndViewMode(
.flatMapMany(childApplicationId -> repository.findNonComposedByApplicationIdAndViewMode(
childApplicationId, viewMode, actionPermission.getReadPermission()));
}
String pageId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface CustomActionCollectionRepositoryCE extends AppsmithRepository<A
Flux<ActionCollection> findByApplicationId(
String applicationId, Optional<AclPermission> aclPermission, Optional<Sort> sort);

Flux<ActionCollection> findByApplicationIdAndViewMode(
Flux<ActionCollection> findNonComposedByApplicationIdAndViewMode(
String applicationId, boolean viewMode, AclPermission aclPermission);

Flux<ActionCollection> findByPageId(String pageId, AclPermission permission);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected BridgeQuery<ActionCollection> getBridgeQueryForFindByApplicationIdAndV
}

@Override
public Flux<ActionCollection> findByApplicationIdAndViewMode(
public Flux<ActionCollection> findNonComposedByApplicationIdAndViewMode(
String applicationId, boolean viewMode, AclPermission aclPermission) {
BridgeQuery<ActionCollection> bridgeQuery =
getBridgeQueryForFindByApplicationIdAndViewMode(applicationId, viewMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ public void jsActionWithoutCollectionIdShouldBeIgnoredDuringNameChecking() {
mockActionCollectionDTO.setName("testCollection");
mockActionCollectionDTO.setActions(List.of(firstAction, secondAction));

Mockito.when(actionCollectionService.getActionCollectionsByViewMode(Mockito.any(), Mockito.anyBoolean()))
Mockito.when(actionCollectionService.getNonComposedActionCollectionsByViewMode(
Mockito.any(), Mockito.anyBoolean()))
.thenReturn(Flux.just(mockActionCollectionDTO));

Mono<Boolean> nameAllowedMono = refactoringService.isNameAllowed(
Expand Down

0 comments on commit 2671d59

Please sign in to comment.