use of org.hisp.dhis.webapi.webdomain.WebOptions in project dhis2-core by dhis2.
the class PaginationHelperTest method testPaginateWhenIntermediatePage.
@Test
void testPaginateWhenIntermediatePage() {
// Given
final int pageSize = 5;
final int secondPage = 2;
final int totalOfItems = 13;
final WebOptions theWebOptions = mockWebOptions(pageSize, secondPage);
final List<DataItem> anyDimensionalItems = mockDimensionalItems(totalOfItems);
// When
final List<DataItem> resultingList = paginate(theWebOptions, anyDimensionalItems);
// Then
assertThat(resultingList, hasSize(5));
}
use of org.hisp.dhis.webapi.webdomain.WebOptions in project dhis2-core by dhis2.
the class PaginationHelperTest method testPaginateWhenLastPage.
@Test
void testPaginateWhenLastPage() {
// Given
final int pageSize = 5;
final int lastPage = 3;
final int totalOfItems = 13;
final WebOptions theWebOptions = mockWebOptions(pageSize, lastPage);
final List<DataItem> anyDimensionalItems = mockDimensionalItems(totalOfItems);
// When
final List<DataItem> resultingList = paginate(theWebOptions, anyDimensionalItems);
// Then
assertThat(resultingList, hasSize(3));
}
use of org.hisp.dhis.webapi.webdomain.WebOptions in project dhis2-core by dhis2.
the class PaginationHelperTest method testPaginateWhenPageSizeIsZero.
@Test
void testPaginateWhenPageSizeIsZero() {
// Given
final int pageSize = 0;
final int lastPage = 3;
final int totalOfItems = 13;
final WebOptions theWebOptions = mockWebOptions(pageSize, lastPage);
final List<DataItem> anyDimensionalItems = mockDimensionalItems(totalOfItems);
// When
assertThrows(IllegalStateException.class, () -> paginate(theWebOptions, anyDimensionalItems), "Page size must be greater than zero.");
}
use of org.hisp.dhis.webapi.webdomain.WebOptions in project dhis2-core by dhis2.
the class PaginationHelperTest method testPaginateWhenFirstPage.
@Test
void testPaginateWhenFirstPage() {
// Given
final int pageSize = 5;
final int firstPage = 1;
final int totalOfItems = 13;
final WebOptions theWebOptions = mockWebOptions(pageSize, firstPage);
final List<DataItem> anyDimensionalItems = mockDimensionalItems(totalOfItems);
// When
final List<DataItem> resultingList = paginate(theWebOptions, anyDimensionalItems);
// Then
assertThat(resultingList, hasSize(5));
}
use of org.hisp.dhis.webapi.webdomain.WebOptions in project dhis2-core by dhis2.
the class DimensionItemPageHandlerTest method testAddPaginationToNodeWhenPagingIsFalse.
@Test
void testAddPaginationToNodeWhenPagingIsFalse() {
// Given
final RootNode anyRootNode = new RootNode("any");
final WebOptions webOptionsNoPaging = mockWebOptionsWithPagingFlagFalse();
final String anyUid = "LFsZ8v5v7rq";
final int anyTotals = 12;
// When
dimensionItemPageHandler.addPaginationToNodeIfEnabled(anyRootNode, webOptionsNoPaging, anyUid, anyTotals);
// Then
assertThat(anyRootNode, is(notNullValue()));
assertThat(anyRootNode.getName(), is(equalTo("any")));
assertThat(anyRootNode.getChildren(), is(empty()));
verify(linkService, never()).generatePagerLinks(any(Pager.class), anyString());
}
Aggregations