Skip to content

Commit

Permalink
feat: TE analytics API - Meta data should return only dimension and f…
Browse files Browse the repository at this point in the history
…ilter objects[DHIS2-16533_2] (#16648)

* feat: TE analytics API - Meta data should return only dimension and filter objects[DHIS2-16533_2]

* feat: TE analytics API - Meta data should return only dimension and filter objects[DHIS2-16533_2]

* spotless

* QA issues

* QA issues

* QA issues
  • Loading branch information
d-bernat authored Feb 28, 2024
1 parent 321c0cd commit d5f71d1
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import static org.hisp.dhis.feedback.ErrorCode.E7251;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -111,12 +110,7 @@ public class CommonQueryRequestMapper {
* @param request the input {@CommonQueryRequest}.
* @return the {@link CommonParams}.
*/
public CommonParams map(CommonQueryRequest request) {
CommonQueryRequest originalRequest =
request
.withDimension(ImmutableSet.copyOf(request.getDimension()))
.withFilter(ImmutableSet.copyOf(request.getFilter()));

public CommonParams map(CommonQueryRequest request, CommonQueryRequest originalRequest) {
List<OrganisationUnit> userOrgUnits =
dataQueryService.getUserOrgUnits(null, request.getUserOrgUnit());
List<Program> programs = getPrograms(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,11 @@ Map<String, MetadataItem> handle(Grid grid, CommonParams commonParams) {
List<QueryItem> items =
commonParams.delegate().getAllItems().stream()
.filter(
it ->
isInRequestDimensionOrFilter(
it.getItem().getUid(), commonParams.getOriginalRequest()))
it -> isInOriginalRequest(it.getItem().getUid(), commonParams.getOriginalRequest()))
.toList();
Set<Option> itemOptions =
commonParams.delegate().getItemsOptions().stream()
.filter(
o -> isInRequestDimensionOrFilter(o.getUid(), commonParams.getOriginalRequest()))
.filter(o -> isInOriginalRequest(o.getUid(), commonParams.getOriginalRequest()))
.collect(toSet());
Map<String, List<Option>> optionsPresentInGrid = getItemOptions(grid, items);
Set<Option> optionItems = getOptionItems(grid, itemOptions, items, optionsPresentInGrid);
Expand All @@ -110,13 +107,11 @@ Map<String, MetadataItem> handle(Grid grid, CommonParams commonParams) {
Set<Legend> itemLegends = commonParams.delegate().getItemsLegends();
List<Program> programs =
commonParams.getPrograms().stream()
.filter(
p -> isInRequestDimensionOrFilter(p.getUid(), commonParams.getOriginalRequest()))
.filter(p -> isInOriginalRequest(p.getUid(), commonParams.getOriginalRequest()))
.toList();
Set<ProgramStage> programStages =
commonParams.delegate().getProgramStages().stream()
.filter(
p -> isInRequestDimensionOrFilter(p.getUid(), commonParams.getOriginalRequest()))
.filter(p -> isInOriginalRequest(p.getUid(), commonParams.getOriginalRequest()))
.collect(toSet());
boolean includeMetadataDetails = commonParams.isIncludeMetadataDetails();
DisplayProperty displayProperty = commonParams.getDisplayProperty();
Expand Down Expand Up @@ -176,16 +171,20 @@ Map<String, MetadataItem> handle(Grid grid, CommonParams commonParams) {
* considered to be in dimension or filter set.
*
* @param uid
* @param request the {@link CommonQueryRequest}.
* @param originalRequest the {@link CommonQueryRequest}.
* @return the boolean indicator.
*/
private boolean isInRequestDimensionOrFilter(String uid, CommonQueryRequest request) {
if (request == null) {
private boolean isInOriginalRequest(String uid, CommonQueryRequest originalRequest) {
if (originalRequest == null) {
return true;
}

return request.getDimension().stream().anyMatch(uId -> uId.contains(uid))
|| request.getFilter().stream().anyMatch(uId -> uId.contains(uid));
return originalRequest.getDimension().stream().anyMatch(uId -> uId.contains(uid))
|| originalRequest.getFilter().stream().anyMatch(uId -> uId.contains(uid))
|| originalRequest.getHeaders().stream().anyMatch(uId -> uId.contains(uid))
|| originalRequest.getProgram().stream().anyMatch(uId -> uId.contains(uid))
|| originalRequest.getAsc().stream().anyMatch(uId -> uId.contains(uid))
|| originalRequest.getDesc().stream().anyMatch(uId -> uId.contains(uid));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.analytics.common.CommonQueryRequest;
import org.hisp.dhis.analytics.common.QueryRequest;
import org.hisp.dhis.analytics.common.processing.CommonQueryRequestMapper;
import org.hisp.dhis.analytics.common.processing.Processor;
Expand Down Expand Up @@ -73,7 +74,8 @@ public class TeiQueryRequestMapper {
* @throws IllegalQueryException if the current TrackedEntityType specified in the given request
* is invalid or non-existent.
*/
public TeiQueryParams map(QueryRequest<TeiQueryRequest> queryRequest) {
public TeiQueryParams map(
QueryRequest<TeiQueryRequest> queryRequest, CommonQueryRequest originalRequest) {
TrackedEntityType trackedEntityType =
getTrackedEntityType(queryRequest.getRequest().getTrackedEntityType());

Expand All @@ -100,7 +102,7 @@ public TeiQueryParams map(QueryRequest<TeiQueryRequest> queryRequest) {
.trackedEntityType(trackedEntityType)
.commonParams(
commonQueryRequestMapper
.map(queryRequest.getCommonQueryRequest())
.map(queryRequest.getCommonQueryRequest(), originalRequest)
.withProgramsFromRequest(programsFromRequest))
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void mapWithSuccessOnlyDimension() {
eventDataQueryService,
programService,
dimensionIdentifierConverter)
.map(aCommonQueryRequest);
.map(aCommonQueryRequest, aCommonQueryRequest);

// Then
assertEquals(2, params.getPrograms().size(), "Should contain 2 programs.");
Expand Down Expand Up @@ -240,7 +240,7 @@ void mapWithSuccessOnlyFilter() {
eventDataQueryService,
programService,
dimensionIdentifierConverter)
.map(aCommonQueryRequest);
.map(aCommonQueryRequest, aCommonQueryRequest);

// Then
assertEquals(2, params.getPrograms().size(), "Should contain 2 programs.");
Expand Down Expand Up @@ -363,7 +363,7 @@ void mapWithSuccessDimensionAndFilter() {
eventDataQueryService,
programService,
dimensionIdentifierConverter)
.map(aCommonQueryRequest);
.map(aCommonQueryRequest, aCommonQueryRequest);

// Then
assertEquals(2, params.getPrograms().size(), "Should contain 2 programs.");
Expand Down Expand Up @@ -434,7 +434,8 @@ void mapWhenProgramsCannotBeFound() {
// When
IllegalQueryException thrown =
assertThrows(
IllegalQueryException.class, () -> commonQueryRequestMapper.map(aCommonQueryRequest));
IllegalQueryException.class,
() -> commonQueryRequestMapper.map(aCommonQueryRequest, aCommonQueryRequest));

// Then
assertEquals(
Expand Down Expand Up @@ -499,7 +500,7 @@ void mapWhenDimensionIsNotObject() {
eventDataQueryService,
programService,
dimensionIdentifierConverter)
.map(aCommonQueryRequest);
.map(aCommonQueryRequest, aCommonQueryRequest);

// Then
assertEquals(2, params.getPrograms().size(), "Should contain 2 programs.");
Expand Down Expand Up @@ -573,7 +574,8 @@ void mapWhenDimensionIsNotObjectAndProgramAndStageAreNotSet() {
// When
IllegalQueryException thrown =
assertThrows(
IllegalQueryException.class, () -> commonQueryRequestMapper.map(aCommonQueryRequest));
IllegalQueryException.class,
() -> commonQueryRequestMapper.map(aCommonQueryRequest, aCommonQueryRequest));

// Then
assertEquals(
Expand Down Expand Up @@ -655,7 +657,7 @@ void mapWhenOrIsUsed() {
eventDataQueryService,
programService,
dimensionIdentifierConverter)
.map(aCommonQueryRequest);
.map(aCommonQueryRequest, aCommonQueryRequest);

Set<String> groups =
params.getDimensionIdentifiers().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ void testValidateTrackedEntityType(String trackedEntityTypeUid, String expectedM

when(programService.getPrograms(Set.of("A", "B"))).thenReturn(Set.of(programA, programB));

CommonQueryRequest commonQueryRequest = new CommonQueryRequest();

final IllegalQueryException thrown =
assertThrows(IllegalQueryException.class, () -> teiQueryRequestMapper.map(queryRequest));
assertThrows(
IllegalQueryException.class,
() -> teiQueryRequestMapper.map(queryRequest, commonQueryRequest));

assertEquals(expectedMessage, thrown.getMessage());
}
Expand All @@ -126,9 +130,9 @@ void testOK() {

when(programService.getPrograms(Set.of("A", "B"))).thenReturn(Set.of(programA, programB));

when(commonQueryRequestMapper.map(any())).thenReturn(CommonParams.builder().build());
when(commonQueryRequestMapper.map(any(), any())).thenReturn(CommonParams.builder().build());

assertDoesNotThrow(() -> teiQueryRequestMapper.map(queryRequest));
assertDoesNotThrow(() -> teiQueryRequestMapper.map(queryRequest, new CommonQueryRequest()));
}

@Test
Expand All @@ -148,9 +152,9 @@ void testOKWhenNoPrograms() {

when(programService.getPrograms(Set.of("A", "B"))).thenReturn(Set.of());

when(commonQueryRequestMapper.map(any())).thenReturn(CommonParams.builder().build());
when(commonQueryRequestMapper.map(any(), any())).thenReturn(CommonParams.builder().build());

assertDoesNotThrow(() -> teiQueryRequestMapper.map(queryRequest));
assertDoesNotThrow(() -> teiQueryRequestMapper.map(queryRequest, new CommonQueryRequest()));
}

private Program stubProgram(String uid, String tetUid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void queryTrackedentityquerywithrowcontext1() throws JSONException {

// Assert metaData.
String expectedMetaData =
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"lZGmxYbs97q\":{\"name\":\"Unique ID\"},\"zDhUuAYrxNC\":{\"name\":\"Last name\"},\"Mnp3oXrpAbK\":{\"code\":\"Female\",\"name\":\"Female\"},\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"rBvjJYbMCVx\":{\"code\":\"Male\",\"name\":\"Male\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"w75KJ2mc4zz\":{\"name\":\"First name\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"pC3N9N77UmT\":{\"uid\":\"pC3N9N77UmT\",\"name\":\"Gender\",\"options\":[{\"uid\":\"rBvjJYbMCVx\",\"code\":\"Male\"},{\"uid\":\"Mnp3oXrpAbK\",\"code\":\"Female\"}]},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"Mnp3oXrpAbK\":{\"code\":\"Female\",\"name\":\"Female\"},\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"rBvjJYbMCVx\":{\"code\":\"Male\",\"name\":\"Male\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"pC3N9N77UmT\":{\"uid\":\"pC3N9N77UmT\",\"name\":\"Gender\",\"options\":[{\"uid\":\"rBvjJYbMCVx\",\"code\":\"Male\"},{\"uid\":\"Mnp3oXrpAbK\",\"code\":\"Female\"}]},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString();
assertEquals(expectedMetaData, actualMetaData, false);

Expand Down Expand Up @@ -317,7 +317,7 @@ public void queryTrackedentityquerywithrowcontext2() throws JSONException {

// Assert metaData.
String expectedMetaData =
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"lZGmxYbs97q\":{\"name\":\"Unique ID\"},\"zDhUuAYrxNC\":{\"name\":\"Last name\"},\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"w75KJ2mc4zz\":{\"name\":\"First name\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString();
assertEquals(expectedMetaData, actualMetaData, false);

Expand Down Expand Up @@ -382,7 +382,7 @@ public void queryTrackedentityquerywithrowcontext3() throws JSONException {

// Assert metaData.
String expectedMetaData =
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"lZGmxYbs97q\":{\"name\":\"Unique ID\"},\"zDhUuAYrxNC\":{\"name\":\"Last name\"},\"Mnp3oXrpAbK\":{\"code\":\"Female\",\"name\":\"Female\"},\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"rBvjJYbMCVx\":{\"code\":\"Male\",\"name\":\"Male\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"w75KJ2mc4zz\":{\"name\":\"First name\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"pC3N9N77UmT\":{\"uid\":\"pC3N9N77UmT\",\"name\":\"Gender\",\"options\":[{\"uid\":\"rBvjJYbMCVx\",\"code\":\"Male\"},{\"uid\":\"Mnp3oXrpAbK\",\"code\":\"Female\"}]},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"Mnp3oXrpAbK\":{\"code\":\"Female\",\"name\":\"Female\"},\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"rBvjJYbMCVx\":{\"code\":\"Male\",\"name\":\"Male\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"pC3N9N77UmT\":{\"uid\":\"pC3N9N77UmT\",\"name\":\"Gender\",\"options\":[{\"uid\":\"rBvjJYbMCVx\",\"code\":\"Male\"},{\"uid\":\"Mnp3oXrpAbK\",\"code\":\"Female\"}]},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString();
assertEquals(expectedMetaData, actualMetaData, false);

Expand Down Expand Up @@ -715,7 +715,7 @@ public void queryTrackedentityquerywithrowcontext4() throws JSONException {

// Assert metaData.
String expectedMetaData =
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"lZGmxYbs97q\":{\"name\":\"Unique ID\"},\"zDhUuAYrxNC\":{\"name\":\"Last name\"},\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"w75KJ2mc4zz\":{\"name\":\"First name\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
"{\"pager\":{\"isLastPage\":false,\"pageSize\":10,\"page\":1},\"items\":{\"IpHINAT79UW.A03MvHHogjR.a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"a3kGcGDCuk6\":{\"name\":\"MCH Apgar Score\"},\"IpHINAT79UW.A03MvHHogjR.UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"},\"UXz7xuGCEhU\":{\"name\":\"MCH Weight (g)\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[],\"w75KJ2mc4zz\":[],\"a3kGcGDCuk6\":[],\"UXz7xuGCEhU\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString();
assertEquals(expectedMetaData, actualMetaData, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,6 @@ public void queryWithProgramAndManyParams() {
.body("metaData.pager", not(hasKey("total")))
.body("metaData.pager", not(hasKey("pageCount")))
.body("metaData.items.ImspTQPwCqd.name", equalTo(null))
.body("metaData.items.lZGmxYbs97q.name", equalTo("Unique ID"))
.body("metaData.items.zDhUuAYrxNC.name", equalTo("Last name"))
.body("metaData.items.w75KJ2mc4zz.name", equalTo("First name"))
.body("metaData.items.cejWyOfXge6.name", equalTo("Gender"))
.body("metaData.items.ou.name", equalTo(null))
Expand Down Expand Up @@ -618,8 +616,6 @@ public void queryWithProgramDimensionAndFilter() {
.body("metaData.pager", not(hasKey("total")))
.body("metaData.pager", not(hasKey("pageCount")))
.body("metaData.items.ImspTQPwCqd.name", equalTo(null))
.body("metaData.items.lZGmxYbs97q.name", equalTo("Unique ID"))
.body("metaData.items.zDhUuAYrxNC.name", equalTo("Last name"))
.body("metaData.items.w75KJ2mc4zz.name", equalTo("First name"))
.body("metaData.items.ou.name", equalTo(null))
.body("metaData.dimensions", hasKey("lZGmxYbs97q"))
Expand Down Expand Up @@ -1819,7 +1815,7 @@ public void queryWithProgramAndEnrollmentDateOffset() throws JSONException {

// Assert metaData.
String expectedMetaData =
"{\"pager\":{\"page\":1,\"pageSize\":50,\"isLastPage\":false},\"items\":{\"lZGmxYbs97q\":{\"name\":\"Unique ID\"},\"zDhUuAYrxNC\":{\"name\":\"Last name\"},\"pe\":{\"name\":\"Period\"},\"IpHINAT79UW.pe\":{\"name\":\"Period\"},\"w75KJ2mc4zz\":{\"name\":\"First name\"},\"2022\":{\"name\":\"2022\"},\"LAST_YEAR\":{\"name\":\"Last year\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[\"2022\"],\"w75KJ2mc4zz\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
"{\"pager\":{\"page\":1,\"pageSize\":50,\"isLastPage\":false},\"items\":{\"zDhUuAYrxNC\":{\"name\":\"Last name\"},\"pe\":{\"name\":\"Period\"},\"IpHINAT79UW\":{\"name\":\"Child Programme\"},\"ZzYYXq4fJie\":{\"name\":\"Baby Postnatal\"},\"IpHINAT79UW.pe\":{\"name\":\"Period\"},\"w75KJ2mc4zz\":{\"name\":\"First name\"},\"A03MvHHogjR\":{\"name\":\"Birth\"},\"2022\":{\"name\":\"2022\"},\"LAST_YEAR\":{\"name\":\"Last year\"}},\"dimensions\":{\"lZGmxYbs97q\":[],\"zDhUuAYrxNC\":[],\"pe\":[\"2022\"],\"w75KJ2mc4zz\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"]}}";
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString();
assertEquals(expectedMetaData, actualMetaData, false);

Expand Down
Loading

0 comments on commit d5f71d1

Please sign in to comment.