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

fix: condition to check eligible headers [DHIS2-16191] #16036

Merged
merged 2 commits into from
Dec 28, 2023
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 @@ -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);
}
}
Loading