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

test: move event order tests into OrderAndPaginationExporterTest DHIS2-15900 #16058

Merged
merged 1 commit into from
Jan 4, 2024
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 @@ -520,7 +520,7 @@ void shouldOrderTrackedEntitiesByMultipleAttributesDesc()

@Test
void shouldReturnPaginatedEnrollmentsGivenNonDefaultPageSize()
throws ForbiddenException, BadRequestException, NotFoundException {
throws ForbiddenException, BadRequestException {
EnrollmentOperationParams operationParams =
EnrollmentOperationParams.builder()
.orgUnitUids(Set.of(orgUnit.getUid()))
Expand Down Expand Up @@ -552,7 +552,7 @@ void shouldReturnPaginatedEnrollmentsGivenNonDefaultPageSize()

@Test
void shouldReturnPaginatedEnrollmentsGivenNonDefaultPageSizeAndTotalPages()
throws ForbiddenException, BadRequestException, NotFoundException {
throws ForbiddenException, BadRequestException {
EnrollmentOperationParams operationParams =
EnrollmentOperationParams.builder()
.orgUnitUids(Set.of(orgUnit.getUid()))
Expand Down Expand Up @@ -584,7 +584,7 @@ void shouldReturnPaginatedEnrollmentsGivenNonDefaultPageSizeAndTotalPages()

@Test
void shouldOrderEnrollmentsByPrimaryKeyDescByDefault()
throws ForbiddenException, BadRequestException, NotFoundException {
throws ForbiddenException, BadRequestException {
Enrollment nxP7UnKhomJ = get(Enrollment.class, "nxP7UnKhomJ");
Enrollment TvctPPhpD8z = get(Enrollment.class, "TvctPPhpD8z");
List<String> expected =
Expand All @@ -605,8 +605,7 @@ void shouldOrderEnrollmentsByPrimaryKeyDescByDefault()
}

@Test
void shouldOrderEnrollmentsByEnrolledAtAsc()
throws ForbiddenException, BadRequestException, NotFoundException {
void shouldOrderEnrollmentsByEnrolledAtAsc() throws ForbiddenException, BadRequestException {
EnrollmentOperationParams params =
EnrollmentOperationParams.builder()
.orgUnitUids(Set.of(orgUnit.getUid()))
Expand All @@ -620,8 +619,7 @@ void shouldOrderEnrollmentsByEnrolledAtAsc()
}

@Test
void shouldOrderEnrollmentsByEnrolledAtDesc()
throws ForbiddenException, BadRequestException, NotFoundException {
void shouldOrderEnrollmentsByEnrolledAtDesc() throws ForbiddenException, BadRequestException {
EnrollmentOperationParams params =
EnrollmentOperationParams.builder()
.orgUnitUids(Set.of(orgUnit.getUid()))
Expand Down Expand Up @@ -1008,6 +1006,66 @@ void shouldOrderEventsByOccurredAtAsc() throws ForbiddenException, BadRequestExc
assertEquals(List.of("pTzf9KYMk72", "D9PbzJY8bJM"), events);
}

@Test
void shouldOrderEventsByCreatedAtClientInAscOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
eventParamsBuilder
.orgUnitUid(orgUnit.getUid())
.programStageUid(programStage.getUid())
.orderBy("createdAtClient", SortDirection.ASC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("D9PbzJY8bJM", "pTzf9KYMk72"), events);
}

@Test
void shouldOrderEventsByCreatedAtClientInDescOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
eventParamsBuilder
.orgUnitUid(orgUnit.getUid())
.programStageUid(programStage.getUid())
.orderBy("createdAtClient", SortDirection.DESC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("pTzf9KYMk72", "D9PbzJY8bJM"), events);
}

@Test
void shouldOrderEventsByUpdatedAtClientInAscOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
eventParamsBuilder
.orgUnitUid(orgUnit.getUid())
.programStageUid(programStage.getUid())
.orderBy("lastUpdatedAtClient", SortDirection.ASC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("pTzf9KYMk72", "D9PbzJY8bJM"), events);
}

@Test
void shouldOrderEventsByUpdatedAtClientInDescOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
eventParamsBuilder
.orgUnitUid(orgUnit.getUid())
.programStageUid(programStage.getUid())
.orderBy("lastUpdatedAtClient", SortDirection.DESC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("D9PbzJY8bJM", "pTzf9KYMk72"), events);
}

@Test
void shouldOrderEventsRespectingOrderWhenAttributeOrderSuppliedBeforeOrderParam()
throws ForbiddenException, BadRequestException {
Expand Down Expand Up @@ -1300,7 +1358,7 @@ private List<String> getTrackedEntities(TrackedEntityOperationParams params)
}

private List<String> getEnrollments(EnrollmentOperationParams params)
throws ForbiddenException, BadRequestException, NotFoundException {
throws ForbiddenException, BadRequestException {
return uids(enrollmentService.getEnrollments(params));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import org.hisp.dhis.tracker.imports.TrackerImportService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.util.DateUtils;
import org.hisp.dhis.webapi.controller.event.mapper.SortDirection;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
Expand Down Expand Up @@ -180,62 +179,6 @@ void shouldReturnEventsWithNotes() throws ForbiddenException, BadRequestExceptio
() -> assertNote(importUser, "comment value", notes.get(1)));
}

@Test
void shouldOrderEventsByCreatedAtClientInAscOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
operationParamsBuilder
.programStageUid(programStage.getUid())
.orderBy("createdAtClient", SortDirection.ASC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("D9PbzJY8bJM", "pTzf9KYMk72"), events);
}

@Test
void shouldOrderEventsByCreatedAtClientInDescOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
operationParamsBuilder
.programStageUid(programStage.getUid())
.orderBy("createdAtClient", SortDirection.DESC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("pTzf9KYMk72", "D9PbzJY8bJM"), events);
}

@Test
void shouldOrderEventsByUpdatedAtClientInAscOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
operationParamsBuilder
.programStageUid(programStage.getUid())
.orderBy("lastUpdatedAtClient", SortDirection.ASC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("pTzf9KYMk72", "D9PbzJY8bJM"), events);
}

@Test
void shouldOrderEventsByUpdatedAtClientInDescOrder()
throws ForbiddenException, BadRequestException {
EventOperationParams params =
operationParamsBuilder
.programStageUid(programStage.getUid())
.orderBy("lastUpdatedAtClient", SortDirection.DESC)
.build();

List<String> events = getEvents(params);

assertEquals(List.of("D9PbzJY8bJM", "pTzf9KYMk72"), events);
}

@Test
void testExportEvents() throws ForbiddenException, BadRequestException {
EventOperationParams params =
Expand Down
Loading