Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix default values for pagination in tracker exporters #15779

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
package org.hisp.dhis.webapi.controller.tracker.export;

import java.util.Objects;
import org.hisp.dhis.common.OpenApi;

/**
Expand Down Expand Up @@ -61,7 +60,7 @@ public interface PageRequestParams {
*/
@OpenApi.Ignore
default boolean isPaged() {
return Objects.requireNonNullElse(getSkipPaging(), true);
return !Boolean.TRUE.equals(getSkipPaging());
}

/** Indicates whether to include the total number of items and pages in the paginated response. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private static boolean orgUnitModeDoesNotRequireOrgUnit(

public static void validatePaginationParameters(PageRequestParams params)
throws BadRequestException {
if (Boolean.TRUE.equals(params.getSkipPaging())
if (!params.isPaged()
&& (ObjectUtils.firstNonNull(params.getPage(), params.getPageSize()) != null
|| Boolean.TRUE.equals(params.getTotalPages()))) {
throw new BadRequestException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ void shouldBePagedIfSkipPagingIsNull() {
}

@Test
void shouldBePagedIfSkipPagingIsTrue() {
void shouldBePagedIfSkipPagingIsFalse() {
PaginationParameters parameters = new PaginationParameters();
parameters.setSkipPaging(true);
parameters.setSkipPaging(false);

assertTrue(parameters.isPaged());
}

@Test
void shouldBeUnpagedIfSkipPagingIsTrue() {
PaginationParameters parameters = new PaginationParameters();
parameters.setSkipPaging(false);
parameters.setSkipPaging(true);

assertFalse(parameters.isPaged());
}
Expand Down
Loading