|
1 | 1 | package de.symeda.sormas.backend.facility; |
2 | 2 |
|
| 3 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 4 | +import static org.hamcrest.Matchers.empty; |
| 5 | +import static org.hamcrest.Matchers.is; |
3 | 6 | import static org.junit.Assert.assertEquals; |
4 | 7 | import static org.junit.Assert.assertFalse; |
5 | 8 |
|
| 9 | +import java.util.ArrayList; |
6 | 10 | import java.util.Collections; |
7 | 11 | import java.util.Date; |
8 | 12 | import java.util.List; |
9 | 13 |
|
10 | 14 | import org.junit.Test; |
11 | 15 |
|
| 16 | +import de.symeda.sormas.api.facility.FacilityCriteria; |
12 | 17 | import de.symeda.sormas.api.facility.FacilityDto; |
13 | 18 | import de.symeda.sormas.api.facility.FacilityType; |
14 | 19 | import de.symeda.sormas.api.region.CommunityReferenceDto; |
15 | 20 | import de.symeda.sormas.api.region.DistrictReferenceDto; |
| 21 | +import de.symeda.sormas.api.utils.SortProperty; |
16 | 22 | import de.symeda.sormas.backend.AbstractBeanTest; |
17 | 23 | import de.symeda.sormas.backend.TestDataCreator.RDCF; |
18 | 24 | import de.symeda.sormas.backend.region.Community; |
@@ -132,4 +138,35 @@ public void testHasArchivedParentInfrastructureNoFacilities() { |
132 | 138 |
|
133 | 139 | assertFalse(getFacilityFacade().hasArchivedParentInfrastructure(Collections.emptyList())); |
134 | 140 | } |
| 141 | + |
| 142 | + @Test |
| 143 | + public void testGetIndexListMappedSorting() { |
| 144 | + |
| 145 | + FacilityCriteria facilityCriteria = new FacilityCriteria(); |
| 146 | + |
| 147 | + // 0. No sortProperties |
| 148 | + List<FacilityDto> result = getFacilityFacade().getIndexList(facilityCriteria, null, null, new ArrayList<>()); |
| 149 | + assertThat(result, is(empty())); |
| 150 | + |
| 151 | + List<SortProperty> allSortProperties = new ArrayList<>(); |
| 152 | + allSortProperties.add(new SortProperty(FacilityDto.NAME)); |
| 153 | + allSortProperties.add(new SortProperty(FacilityDto.TYPE)); |
| 154 | + allSortProperties.add(new SortProperty(FacilityDto.REGION)); |
| 155 | + allSortProperties.add(new SortProperty(FacilityDto.DISTRICT)); |
| 156 | + allSortProperties.add(new SortProperty(FacilityDto.COMMUNITY)); |
| 157 | + allSortProperties.add(new SortProperty(FacilityDto.CITY)); |
| 158 | + allSortProperties.add(new SortProperty(FacilityDto.LATITUDE)); |
| 159 | + allSortProperties.add(new SortProperty(FacilityDto.LONGITUDE)); |
| 160 | + allSortProperties.add(new SortProperty(FacilityDto.EXTERNAL_ID)); |
| 161 | + |
| 162 | + // 1. Sort by every property |
| 163 | + for (SortProperty sortProperty : allSortProperties) { |
| 164 | + getFacilityFacade().getIndexList(facilityCriteria, null, null, Collections.singletonList(sortProperty)); |
| 165 | + assertThat(sortProperty.toString(), result, is(empty())); |
| 166 | + } |
| 167 | + |
| 168 | + // 2. Sort by all properties at once |
| 169 | + getFacilityFacade().getIndexList(facilityCriteria, null, null, allSortProperties); |
| 170 | + assertThat(result, is(empty())); |
| 171 | + } |
135 | 172 | } |
0 commit comments