diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/SearchEntitySolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/SearchEntitySolutionCEImpl.java index 0853a442bf..eddd2004d2 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/SearchEntitySolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/SearchEntitySolutionCEImpl.java @@ -19,6 +19,8 @@ import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.List; +import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.getPageable; +import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.getSort; import static com.appsmith.server.searchentities.helpers.SearchEntityHelper.shouldSearchEntity; @RequiredArgsConstructor @@ -55,8 +57,8 @@ public class SearchEntitySolutionCEImpl implements SearchEntitySolutionCE { if (size == 0) { return Mono.just(new SearchEntityDTO()); } - Pageable pageable = Pageable.ofSize(size).withPage(page); - Sort sort = Sort.by(Sort.Direction.DESC, FieldName.UPDATED_AT); + Pageable pageable = getPageable(page, size); + Sort sort = getSort(); searchString = StringUtils.hasLength(searchString) ? searchString.trim() : ""; // If no entities are specified, search for all entities. Mono> workspacesMono = Mono.just(new ArrayList<>()); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/helpers/SearchEntityHelper.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/helpers/SearchEntityHelper.java index 77bcc00b6c..0ebc56b9cf 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/helpers/SearchEntityHelper.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/searchentities/helpers/SearchEntityHelper.java @@ -1,5 +1,9 @@ package com.appsmith.server.searchentities.helpers; +import com.appsmith.server.constants.FieldName; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; + public class SearchEntityHelper { /** * This method checks if the entity should be searched based on the entities list provided. If the entities list is null or empty, then all entities are searched. @@ -19,4 +23,12 @@ public class SearchEntityHelper { } return false; } + + public static Sort getSort() { + return Sort.by(Sort.Direction.DESC, FieldName.UPDATED_AT); + } + + public static Pageable getPageable(int page, int size) { + return Pageable.ofSize(size).withPage(page); + } } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java similarity index 99% rename from app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionTest.java rename to app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java index cf73f375fd..f67e350bd8 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java @@ -24,7 +24,7 @@ import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.junit.jupiter.api.Assertions.assertNotNull; @SpringBootTest -class SearchEntitySolutionTest { +class SearchEntitySolutionCETest { @Autowired ApplicationPageService applicationPageService;