Skip to content

Commit

Permalink
fix: condition to check eligible headers [DHIS2-16191] (#16036)
Browse files Browse the repository at this point in the history
* fix: condition to check eligible headers [DHIS2-16191]

* test: added e2e test [DHIS2-16191]
  • Loading branch information
gnespolino authored Dec 28, 2023
1 parent 9f2710d commit 19e1ff2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,14 @@ private static Stream<DimensionIdentifier<DimensionParam>> getEligibleParsedHead

/**
* Checks if the given {@link DimensionIdentifier} is eligible to be added as a header. It is
* eligible if it is a static dimension and it is either an event or enrollment dimension, and it
* is not a TEI static field (which is already added to the grid headers).
* eligible if it is a static dimension and it is either an event or enrollment dimension.
*
* @param parsedHeader the {@link DimensionIdentifier}.
* @return true if it is eligible, false otherwise.
*/
private static boolean isEligible(DimensionIdentifier<DimensionParam> parsedHeader) {
return parsedHeader.getDimension().isStaticDimension()
&& (parsedHeader.isEventDimension() || parsedHeader.isEnrollmentDimension())
&& !parsedHeader.getDimension().getStaticDimension().isTeiStaticField();
&& (parsedHeader.isEventDimension() || parsedHeader.isEnrollmentDimension());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2889,4 +2889,33 @@ public void headerParamIncidentDate() {

validateRow(response, 0, List.of("2022-01-01 12:05:00.0"));
}

@Test
public void headerParamOunameIsPresent() {
// Given
QueryParamsBuilder params = new QueryParamsBuilder().add("headers=IpHINAT79UW.ouname");

// When
ApiResponse response = analyticsTeiActions.query().get("nEenWmSyUEp", JSON, JSON, params);

// Then
response
.validate()
.statusCode(200)
.body("rows", hasSize(equalTo(50)))
.body("height", equalTo(50))
.body("width", equalTo(1))
.body("headerWidth", equalTo(1))
.body("headers", hasSize(equalTo(1)));

validateHeader(
response,
0,
"IpHINAT79UW.ouname",
"Enrollment Organisation unit name",
"TEXT",
"java.lang.String",
false,
true);
}
}

0 comments on commit 19e1ff2

Please sign in to comment.