Skip to content

Commit

Permalink
feat: update sstructure removing generic at pagerequest
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Apr 9, 2024
1 parent fc255e3 commit 86d4006
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Expand Up @@ -266,7 +266,7 @@ default Optional<CommunicationEntity> singleResult(SelectQuery query) {
* @throws NullPointerException if the query or pageRequest is null
* @throws IllegalStateException if the cursor-based pagination is used without any order key specified
*/
default CursoredPage<CommunicationEntity> selectCursor(SelectQuery query, PageRequest<?> pageRequest){
default CursoredPage<CommunicationEntity> selectCursor(SelectQuery query, PageRequest pageRequest){
Objects.requireNonNull(query, "query is required");
Objects.requireNonNull(pageRequest, "pageRequest is required");
if(query.sorts().isEmpty()){
Expand Down
Expand Up @@ -41,7 +41,7 @@ class DatabaseManagerTest {
@Test
void shouldReturnErrorWhenThereIsNotSort() {
SelectQuery query = SelectQuery.builder().from("person").build();
PageRequest<?> pageRequest = PageRequest.ofSize(10);
PageRequest pageRequest = PageRequest.ofSize(10);
assertThrows(IllegalArgumentException.class, () -> databaseManager.selectCursor(query, pageRequest));
}

Expand All @@ -57,8 +57,8 @@ void shouldReturnPaginationOffSet() {
PageRequest.ofSize(10));

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest<CommunicationEntity> nextedPageRequest = entities.nextPageRequest();
PageRequest pageRequest = entities.pageRequest();
PageRequest nextedPageRequest = entities.nextPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(2);
Expand All @@ -85,7 +85,7 @@ void shouldReturnPaginationOffSetWhenReturnEmpty() {
PageRequest.ofSize(10));

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest pageRequest = entities.pageRequest();
soft.assertThat(entities.hasNext()).isFalse();
soft.assertThat(entities.hasPrevious()).isFalse();

Expand All @@ -108,8 +108,8 @@ void shouldReturnPaginationOffSet2() {
PageRequest.ofSize(10));

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest<CommunicationEntity> nextedPageRequest = entities.nextPageRequest();
PageRequest pageRequest = entities.pageRequest();
PageRequest nextedPageRequest = entities.nextPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(2);
Expand Down Expand Up @@ -160,8 +160,8 @@ void shouldReturnPaginationAfterKeySingleElementWhenConditionIsNull() {
});

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest<CommunicationEntity> nextedPageRequest = entities.nextPageRequest();
PageRequest pageRequest = entities.pageRequest();
PageRequest nextedPageRequest = entities.nextPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(2);
Expand Down Expand Up @@ -223,8 +223,8 @@ void shouldReturnPaginationAfterKeySingleElementWhenThereIsCondition() {
});

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest<CommunicationEntity> nextedPageRequest = entities.nextPageRequest();
PageRequest pageRequest = entities.pageRequest();
PageRequest nextedPageRequest = entities.nextPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(2);
Expand Down Expand Up @@ -254,7 +254,7 @@ void shouldFindSubElement() {


assertSoftly(soft -> {
PageRequest<CommunicationEntity> nextedPageRequest = entities.nextPageRequest();
PageRequest nextedPageRequest = entities.nextPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(1);
Expand Down Expand Up @@ -300,8 +300,8 @@ void shouldReturnPaginationBeforeKeySingleElementWhenConditionIsNull() {
});

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest<CommunicationEntity> nextedPageRequest = entities.previousPageRequest();
PageRequest pageRequest = entities.pageRequest();
PageRequest nextedPageRequest = entities.previousPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(2);
Expand Down Expand Up @@ -363,8 +363,8 @@ void shouldReturnPaginationBeforeKeySingleElementWhenThereIsCondition() {
});

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest<CommunicationEntity> nextedPageRequest = entities.previousPageRequest();
PageRequest pageRequest = entities.pageRequest();
PageRequest nextedPageRequest = entities.previousPageRequest();
PageRequest.Cursor cursor = nextedPageRequest.cursor().orElseThrow();

soft.assertThat(entities).hasSize(2);
Expand Down Expand Up @@ -397,7 +397,7 @@ void shouldReturnPaginationAfterKeyAndReturnEmpty() {
PageRequest.ofSize(10).afterKey("Ada", 20, id));

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest pageRequest = entities.pageRequest();

soft.assertThat(entities).isEmpty();
soft.assertThat(entities.hasNext()).isFalse();
Expand All @@ -423,7 +423,7 @@ void shouldReturnPaginationBeforeKeyAndReturnEmpty() {
PageRequest.ofSize(10).beforeKey("Ada", 20, id));

assertSoftly(soft -> {
PageRequest<CommunicationEntity> pageRequest = entities.pageRequest();
PageRequest pageRequest = entities.pageRequest();

soft.assertThat(entities).isEmpty();
soft.assertThat(entities.hasNext()).isFalse();
Expand Down
Expand Up @@ -447,8 +447,8 @@ void shouldDeleteAll(){

@Test
void shouldSelectCursor(){
PageRequest<CommunicationEntity> request = PageRequest.ofSize(2);
PageRequest<CommunicationEntity> afterKey = PageRequest.<CommunicationEntity>ofSize(2)
PageRequest request = PageRequest.ofSize(2);
PageRequest afterKey = PageRequest.<CommunicationEntity>ofSize(2)
.afterKey("Ada");
SelectQuery query = select().from("Person").orderBy("name").asc().build();

Expand Down

0 comments on commit 86d4006

Please sign in to comment.