Skip to content

Commit

Permalink
feat: add tests for posting and retrieving datasets display options
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaminia Cavallo authored and Flaminia Cavallo committed Jul 1, 2024
1 parent cf7e884 commit 347926c
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.hisp.dhis.web.WebClient;
import org.hisp.dhis.webapi.DhisControllerIntegrationTest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -70,6 +71,37 @@ void getDatasetMetadataDefaultCatComboTest(
assertEquals(expectedDefaultCatComboCount, count, defaultCatComboCondition);
}

@Test
@DisplayName("Dataset display options are correctly saved and retrieved")
void getDatasetMetadataDisplayOptionsTest() {
String expectedDisplayOptions = "{\"aDisplay\": \"option\"}";
String dataSetsBody =
"""
{
"dataSets": [
{
"name": "hellobrenda",
"shortName": "hellobrenda",
"periodType": "Daily",
"displayOptions": "{\\"aDisplay\\": \\"option\\"}"
}
]
}
""";

// given
POST("/metadata", WebClient.Body(dataSetsBody)).content(HttpStatus.OK);

// when the data entry metadata is retrieves
JsonObject dataEntryMetadata = GET("/dataEntry/metadata").content();
JsonArray dataSets = dataEntryMetadata.getArray("dataSets");
String actualDisplayOptions = dataSets.getObject(0).getString("displayOptions").string();

// then
assertEquals(1, dataSets.size());
assertEquals(expectedDisplayOptions, actualDisplayOptions);
}

private static Stream<Arguments> defaultCatComboData() {
return Stream.of(
Arguments.of(
Expand Down

0 comments on commit 347926c

Please sign in to comment.