-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: order of headers in TE analytics endpoint - Improve Data Visuali…
…zer with fixed period "Weekly (Start Sunday)" labels [DHIS2-17974] [2.42-DHIS2-17955] (#18475) * fix: fixes deprecated field usage [DHIS2-17908] Signed-off-by: Giuseppe Nespolino <[email protected]> * Improve Data Visualizer with fixed period "Weekly (Start Sunday)" labels[2.42-DHIS2-17955] * Improve Data Visualizer with fixed period "Weekly (Start Sunday)" labels[2.42-DHIS2-17955] * e2e tests * NoAnalyticsTable e2e tests fix * NoAnalyticsTable e2e tests fix * NoAnalyticsTable e2e tests fix * decoded urls * fix: fixes deprecated field usage [DHIS2-17908] Signed-off-by: Giuseppe Nespolino <[email protected]> * fix: formatting [DHIS2-17974] Signed-off-by: Giuseppe Nespolino <[email protected]> --------- Signed-off-by: Giuseppe Nespolino <[email protected]> Co-authored-by: d-bernat <[email protected]>
- Loading branch information
1 parent
49942a2
commit b63da1d
Showing
11 changed files
with
640 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
...-test-e2e/src/test/java/org/hisp/dhis/analytics/aggregate/AnalyticsQueryDv13AutoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* | ||
* Copyright (c) 2004-2024, University of Oslo | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the HISP project nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package org.hisp.dhis.analytics.aggregate; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hisp.dhis.analytics.ValidationHelper.validateHeader; | ||
import static org.hisp.dhis.analytics.ValidationHelper.validateRow; | ||
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.hisp.dhis.AnalyticsApiTest; | ||
import org.hisp.dhis.test.e2e.actions.RestApiActions; | ||
import org.hisp.dhis.test.e2e.dto.ApiResponse; | ||
import org.hisp.dhis.test.e2e.helpers.QueryParamsBuilder; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** Groups e2e tests for "/analytics" aggregate endpoint. */ | ||
public class AnalyticsQueryDv13AutoTest extends AnalyticsApiTest { | ||
private RestApiActions actions; | ||
|
||
@BeforeAll | ||
public void setup() { | ||
actions = new RestApiActions("analytics"); | ||
} | ||
|
||
@Test | ||
public void weeklyShortNameLabel() throws JSONException { | ||
// Given | ||
QueryParamsBuilder params = | ||
new QueryParamsBuilder() | ||
.add("filter=ou:USER_ORGUNIT") | ||
.add("skipData=false") | ||
.add("includeNumDen=true") | ||
.add("displayProperty=SHORTNAME") | ||
.add("skipMeta=false") | ||
.add("dimension=dx:fbfJHSPpUQD,pe:2021SunW52"); | ||
|
||
// When | ||
ApiResponse response = actions.get(params); | ||
|
||
// Then | ||
response | ||
.validate() | ||
.statusCode(200) | ||
.body("headers", hasSize(equalTo(8))) | ||
.body("rows", hasSize(equalTo(1))) | ||
.body("height", equalTo(1)) | ||
.body("width", equalTo(8)) | ||
.body("headerWidth", equalTo(8)); | ||
|
||
// Assert metaData. | ||
String expectedMetaData = | ||
"{\"items\":{\"ImspTQPwCqd\":{\"name\":\"Sierra Leone\"},\"dx\":{\"name\":\"Data\"},\"pq2XI5kz2BY\":{\"name\":\"Fixed\"},\"pe\":{\"name\":\"Period\"},\"ou\":{\"name\":\"Organisation unit\"},\"PT59n8BQbqM\":{\"name\":\"Outreach\"},\"2021SunW52\":{\"name\":\"W52 2021-12-26 - 2022-01-01\"},\"fbfJHSPpUQD\":{\"name\":\"ANC 1st visit\"}},\"dimensions\":{\"dx\":[\"fbfJHSPpUQD\"],\"pe\":[\"2021SunW52\"],\"ou\":[\"ImspTQPwCqd\"],\"co\":[\"pq2XI5kz2BY\",\"PT59n8BQbqM\"]}}"; | ||
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString(); | ||
assertEquals(expectedMetaData, actualMetaData, false); | ||
|
||
// Assert headers. | ||
validateHeader(response, 0, "dx", "Data", "TEXT", "java.lang.String", false, true); | ||
validateHeader(response, 1, "pe", "Period", "TEXT", "java.lang.String", false, true); | ||
validateHeader(response, 2, "value", "Value", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader( | ||
response, 3, "numerator", "Numerator", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader( | ||
response, 4, "denominator", "Denominator", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader(response, 5, "factor", "Factor", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader( | ||
response, 6, "multiplier", "Multiplier", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader(response, 7, "divisor", "Divisor", "NUMBER", "java.lang.Double", false, false); | ||
|
||
// Assert rows. | ||
validateRow(response, List.of("fbfJHSPpUQD", "2021SunW52", "462", "", "", "", "", "")); | ||
} | ||
|
||
@Test | ||
public void weeklyNameLabel() throws JSONException { | ||
// Given | ||
QueryParamsBuilder params = | ||
new QueryParamsBuilder() | ||
.add("filter=ou:USER_ORGUNIT") | ||
.add("skipData=false") | ||
.add("includeNumDen=true") | ||
.add("displayProperty=NAME") | ||
.add("skipMeta=false") | ||
.add("dimension=dx:fbfJHSPpUQD,pe:2021SunW52"); | ||
|
||
// When | ||
ApiResponse response = actions.get(params); | ||
|
||
// Then | ||
response | ||
.validate() | ||
.statusCode(200) | ||
.body("headers", hasSize(equalTo(8))) | ||
.body("rows", hasSize(equalTo(1))) | ||
.body("height", equalTo(1)) | ||
.body("width", equalTo(8)) | ||
.body("headerWidth", equalTo(8)); | ||
|
||
// Assert metaData. | ||
String expectedMetaData = | ||
"{\"items\":{\"ImspTQPwCqd\":{\"name\":\"Sierra Leone\"},\"dx\":{\"name\":\"Data\"},\"pq2XI5kz2BY\":{\"name\":\"Fixed\"},\"pe\":{\"name\":\"Period\"},\"ou\":{\"name\":\"Organisation unit\"},\"PT59n8BQbqM\":{\"name\":\"Outreach\"},\"2021SunW52\":{\"name\":\"Week 52 2021-12-26 - 2022-01-01\"},\"fbfJHSPpUQD\":{\"name\":\"ANC 1st visit\"}},\"dimensions\":{\"dx\":[\"fbfJHSPpUQD\"],\"pe\":[\"2021SunW52\"],\"ou\":[\"ImspTQPwCqd\"],\"co\":[\"pq2XI5kz2BY\",\"PT59n8BQbqM\"]}}"; | ||
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString(); | ||
assertEquals(expectedMetaData, actualMetaData, false); | ||
|
||
// Assert headers. | ||
validateHeader(response, 0, "dx", "Data", "TEXT", "java.lang.String", false, true); | ||
validateHeader(response, 1, "pe", "Period", "TEXT", "java.lang.String", false, true); | ||
validateHeader(response, 2, "value", "Value", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader( | ||
response, 3, "numerator", "Numerator", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader( | ||
response, 4, "denominator", "Denominator", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader(response, 5, "factor", "Factor", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader( | ||
response, 6, "multiplier", "Multiplier", "NUMBER", "java.lang.Double", false, false); | ||
validateHeader(response, 7, "divisor", "Divisor", "NUMBER", "java.lang.Double", false, false); | ||
|
||
// Assert rows. | ||
validateRow(response, List.of("fbfJHSPpUQD", "2021SunW52", "462", "", "", "", "", "")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.