Skip to content

Commit

Permalink
test: more consistent TE e2e [DHIS2-14884] (#17758)
Browse files Browse the repository at this point in the history
* test: makes some e2e more consistent [DHIS2-14884]

* test: makes some e2e more consistent [DHIS2-14884]
  • Loading branch information
gnespolino authored Jun 11, 2024
1 parent 00c351b commit 5d70b2b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void sortByGlobalOuAsc() throws JSONException {
QueryParamsBuilder params =
new QueryParamsBuilder()
.add("includeMetadataDetails=true")
.add("asc=ouname")
.add("asc=oucode")
.add("headers=ouname")
.add("displayProperty=NAME")
.add("totalPages=false")
Expand Down Expand Up @@ -89,106 +89,15 @@ public void sortByGlobalOuAsc() throws JSONException {
response, 0, "ouname", "Organisation unit name", "TEXT", "java.lang.String", false, true);

// Assert rows.
validateRow(response, 0, List.of(" Panderu MCHP"));
validateRow(response, 1, List.of(" Panderu MCHP"));
validateRow(response, 2, List.of(" Panderu MCHP"));
validateRow(response, 3, List.of(" Panderu MCHP"));
validateRow(response, 4, List.of(" Panderu MCHP"));
validateRow(response, 5, List.of(" Panderu MCHP"));
validateRow(response, 6, List.of(" Panderu MCHP"));
validateRow(response, 7, List.of(" Panderu MCHP"));
validateRow(response, 8, List.of(" Panderu MCHP"));
validateRow(response, 9, List.of(" Panderu MCHP"));
validateRow(response, 10, List.of(" Panderu MCHP"));
validateRow(response, 11, List.of(" Panderu MCHP"));
validateRow(response, 12, List.of(" Panderu MCHP"));
validateRow(response, 13, List.of(" Panderu MCHP"));
validateRow(response, 14, List.of("Adonkia CHP"));
validateRow(response, 15, List.of("Adonkia CHP"));
validateRow(response, 16, List.of("Adonkia CHP"));
validateRow(response, 17, List.of("Adonkia CHP"));
validateRow(response, 18, List.of("Adonkia CHP"));
validateRow(response, 19, List.of("Adonkia CHP"));
validateRow(response, 20, List.of("Adonkia CHP"));
validateRow(response, 21, List.of("Adonkia CHP"));
validateRow(response, 22, List.of("Adonkia CHP"));
validateRow(response, 23, List.of("Adonkia CHP"));
validateRow(response, 24, List.of("Adonkia CHP"));
validateRow(response, 25, List.of("Adonkia CHP"));
validateRow(response, 26, List.of("Adonkia CHP"));
validateRow(response, 27, List.of("Adonkia CHP"));
validateRow(response, 28, List.of("Adonkia CHP"));
validateRow(response, 29, List.of("Adonkia CHP"));
validateRow(response, 30, List.of("Adonkia CHP"));
validateRow(response, 31, List.of("Adonkia CHP"));
validateRow(response, 32, List.of("Adonkia CHP"));
validateRow(response, 33, List.of("Adonkia CHP"));
validateRow(response, 34, List.of("Adonkia CHP"));
validateRow(response, 35, List.of("Adonkia CHP"));
validateRow(response, 36, List.of("Adonkia CHP"));
validateRow(response, 37, List.of("Adonkia CHP"));
validateRow(response, 38, List.of("Afro Arab Clinic"));
validateRow(response, 39, List.of("Afro Arab Clinic"));
validateRow(response, 40, List.of("Afro Arab Clinic"));
validateRow(response, 41, List.of("Afro Arab Clinic"));
validateRow(response, 42, List.of("Afro Arab Clinic"));
validateRow(response, 43, List.of("Afro Arab Clinic"));
validateRow(response, 44, List.of("Afro Arab Clinic"));
validateRow(response, 45, List.of("Afro Arab Clinic"));
validateRow(response, 46, List.of("Afro Arab Clinic"));
validateRow(response, 47, List.of("Afro Arab Clinic"));
validateRow(response, 48, List.of("Afro Arab Clinic"));
validateRow(response, 49, List.of("Afro Arab Clinic"));
validateRow(response, 50, List.of("Agape CHP"));
validateRow(response, 51, List.of("Agape CHP"));
validateRow(response, 52, List.of("Agape CHP"));
validateRow(response, 53, List.of("Agape CHP"));
validateRow(response, 54, List.of("Agape CHP"));
validateRow(response, 55, List.of("Agape CHP"));
validateRow(response, 56, List.of("Agape CHP"));
validateRow(response, 57, List.of("Agape CHP"));
validateRow(response, 58, List.of("Agape CHP"));
validateRow(response, 59, List.of("Agape CHP"));
validateRow(response, 60, List.of("Agape CHP"));
validateRow(response, 61, List.of("Agape CHP"));
validateRow(response, 62, List.of("Agape CHP"));
validateRow(response, 63, List.of("Agape CHP"));
validateRow(response, 64, List.of("Agape CHP"));
validateRow(response, 65, List.of("Agape CHP"));
validateRow(response, 66, List.of("Agape CHP"));
validateRow(response, 67, List.of("Agape CHP"));
validateRow(response, 68, List.of("Agape CHP"));
validateRow(response, 69, List.of("Agape CHP"));
validateRow(response, 70, List.of("Agape CHP"));
validateRow(response, 71, List.of("Ahamadyya Mission Cl"));
validateRow(response, 72, List.of("Ahamadyya Mission Cl"));
validateRow(response, 73, List.of("Ahamadyya Mission Cl"));
validateRow(response, 74, List.of("Ahamadyya Mission Cl"));
validateRow(response, 75, List.of("Ahamadyya Mission Cl"));
validateRow(response, 76, List.of("Ahamadyya Mission Cl"));
validateRow(response, 77, List.of("Ahamadyya Mission Cl"));
validateRow(response, 78, List.of("Ahamadyya Mission Cl"));
validateRow(response, 79, List.of("Ahamadyya Mission Cl"));
validateRow(response, 80, List.of("Ahamadyya Mission Cl"));
validateRow(response, 81, List.of("Ahamadyya Mission Cl"));
validateRow(response, 82, List.of("Ahamadyya Mission Cl"));
validateRow(response, 83, List.of("Ahamadyya Mission Cl"));
validateRow(response, 84, List.of("Ahamadyya Mission Cl"));
validateRow(response, 85, List.of("Ahamadyya Mission Cl"));
validateRow(response, 86, List.of("Ahamadyya Mission Cl"));
validateRow(response, 87, List.of("Ahamadyya Mission Cl"));
validateRow(response, 88, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 89, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 90, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 91, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 92, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 93, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 94, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 95, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 96, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 97, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 98, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 99, List.of("Ahmadiyya Muslim Hospital"));
validateRow(response, 0, List.of("Praise Foundation CHC"));
validateRow(response, 10, List.of("Praise Foundation CHC"));
validateRow(response, 11, List.of("Bucksal Clinic"));
validateRow(response, 26, List.of("Bucksal Clinic"));
validateRow(response, 27, List.of("Harvest Time MCHP"));
validateRow(response, 35, List.of("Harvest Time MCHP"));
validateRow(response, 36, List.of("Yemoh Town CHC"));
validateRow(response, 48, List.of("Yemoh Town CHC"));
validateRow(response, 49, List.of("Bandajuma MCHP"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ public void sortByEnrollmentOuAsc() throws JSONException {
QueryParamsBuilder params =
new QueryParamsBuilder()
.add("includeMetadataDetails=true")
.add("asc=IpHINAT79UW.ouname")
.add("headers=ouname,gHGyrwKPzej,ciq2USN94oJ,IpHINAT79UW.ouname")
.add("asc=IpHINAT79UW.oucode,lastupdated")
.add("headers=ouname,w75KJ2mc4zz,zDhUuAYrxNC,IpHINAT79UW.ouname,lastupdated")
.add("displayProperty=NAME")
.add("totalPages=false")
.add("rowContext=true")
Expand All @@ -270,25 +270,25 @@ public void sortByEnrollmentOuAsc() throws JSONException {
response
.validate()
.statusCode(200)
.body("headers", hasSize(equalTo(4)))
.body("headers", hasSize(equalTo(5)))
.body("rows", hasSize(equalTo(20)))
.body("height", equalTo(20))
.body("width", equalTo(4))
.body("headerWidth", equalTo(4));
.body("width", equalTo(5))
.body("headerWidth", equalTo(5));

// Assert metaData.
String expectedMetaData =
"{\"pager\":{\"page\":1,\"pageSize\":20,\"isLastPage\":false},\"items\":{\"gHGyrwKPzej\":{\"uid\":\"gHGyrwKPzej\",\"code\":\"MMD_PER_DOB\",\"name\":\"Birth date\",\"description\":\"Birth date\",\"dimensionItemType\":\"PROGRAM_ATTRIBUTE\",\"valueType\":\"DATE\",\"aggregationType\":\"NONE\",\"totalAggregationType\":\"SUM\"},\"ImspTQPwCqd\":{\"uid\":\"ImspTQPwCqd\",\"code\":\"OU_525\",\"name\":\"Sierra Leone\",\"dimensionItemType\":\"ORGANISATION_UNIT\",\"valueType\":\"TEXT\",\"totalAggregationType\":\"SUM\"},\"IpHINAT79UW\":{\"uid\":\"IpHINAT79UW\",\"name\":\"Child Programme\"},\"ZzYYXq4fJie\":{\"uid\":\"ZzYYXq4fJie\",\"name\":\"Baby Postnatal\",\"description\":\"Baby Postnatal\"},\"ciq2USN94oJ\":{\"uid\":\"ciq2USN94oJ\",\"code\":\"MMD_PER_STA\",\"name\":\"Civil status\",\"description\":\"Civil status\",\"dimensionItemType\":\"PROGRAM_ATTRIBUTE\",\"valueType\":\"TEXT\",\"aggregationType\":\"NONE\",\"totalAggregationType\":\"SUM\"},\"ou\":{\"uid\":\"ou\",\"name\":\"Organisation unit\",\"dimensionType\":\"ORGANISATION_UNIT\"},\"USER_ORGUNIT\":{\"organisationUnits\":[\"ImspTQPwCqd\"]},\"A03MvHHogjR\":{\"uid\":\"A03MvHHogjR\",\"name\":\"Birth\",\"description\":\"Birth of the baby\"},\"IpHINAT79UW.ouname\":{\"name\":\"Organisation Unit Name\",\"dimensionType\":\"ORGANISATION_UNIT\"},\"ouname\":{\"name\":\"Organisation Unit Name\",\"dimensionType\":\"ORGANISATION_UNIT\"}},\"dimensions\":{\"zDhUuAYrxNC\":[],\"lw1SqmMlnfh\":[],\"Qo571yj6Zcn\":[],\"DODgdr5Oo2v\":[],\"iESIqZ0R0R0\":[],\"n9nUvfpTsxQ\":[],\"kyIzQsj96BD\":[],\"xs8A6tQJY0s\":[],\"A4xFHyieXys\":[],\"OvY4VVhSDeJ\":[],\"RG7uGl4w5Jq\":[],\"spFvx9FndA4\":[],\"GUOBQt5K2WI\":[],\"Agywv2JGwuq\":[],\"lZGmxYbs97q\":[],\"VqEFza8wbwA\":[],\"ciq2USN94oJ\":[],\"ou\":[\"ImspTQPwCqd\"],\"w75KJ2mc4zz\":[],\"KmEUg2hHEtx\":[],\"G7vUx908SwP\":[],\"o9odfev2Ty5\":[],\"FO4sWYJ64LQ\":[],\"NDXw0cluzSw\":[],\"ruQQnf6rswq\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"],\"P2cwLGskgxn\":[],\"gHGyrwKPzej\":[],\"pe\":[],\"VHfUeXpawmE\":[],\"AuPLng5hLbE\":[],\"ZcBPrXKahq2\":[],\"H9IlTX2X6SL\":[]}}";
"{\"pager\":{\"isLastPage\":false,\"pageSize\":20,\"page\":1},\"items\":{\"gHGyrwKPzej\":{\"uid\":\"gHGyrwKPzej\",\"aggregationType\":\"NONE\",\"code\":\"MMD_PER_DOB\",\"valueType\":\"DATE\",\"name\":\"Birth date\",\"description\":\"Birth date\",\"dimensionItemType\":\"PROGRAM_ATTRIBUTE\",\"totalAggregationType\":\"SUM\"},\"ImspTQPwCqd\":{\"uid\":\"ImspTQPwCqd\",\"code\":\"OU_525\",\"valueType\":\"TEXT\",\"name\":\"Sierra Leone\",\"dimensionItemType\":\"ORGANISATION_UNIT\",\"totalAggregationType\":\"SUM\"},\"zDhUuAYrxNC\":{\"uid\":\"zDhUuAYrxNC\",\"aggregationType\":\"NONE\",\"valueType\":\"TEXT\",\"name\":\"Last name\",\"description\":\"Last name\",\"dimensionItemType\":\"PROGRAM_ATTRIBUTE\",\"totalAggregationType\":\"SUM\"},\"IpHINAT79UW\":{\"uid\":\"IpHINAT79UW\",\"name\":\"Child Programme\"},\"ZzYYXq4fJie\":{\"uid\":\"ZzYYXq4fJie\",\"name\":\"Baby Postnatal\",\"description\":\"Baby Postnatal\"},\"ciq2USN94oJ\":{\"uid\":\"ciq2USN94oJ\",\"aggregationType\":\"NONE\",\"code\":\"MMD_PER_STA\",\"valueType\":\"TEXT\",\"name\":\"Civil status\",\"description\":\"Civil status\",\"dimensionItemType\":\"PROGRAM_ATTRIBUTE\",\"totalAggregationType\":\"SUM\"},\"ou\":{\"uid\":\"ou\",\"dimensionType\":\"ORGANISATION_UNIT\",\"name\":\"Organisation unit\"},\"w75KJ2mc4zz\":{\"uid\":\"w75KJ2mc4zz\",\"aggregationType\":\"NONE\",\"code\":\"MMD_PER_NAM\",\"valueType\":\"TEXT\",\"name\":\"First name\",\"description\":\"First name\",\"dimensionItemType\":\"PROGRAM_ATTRIBUTE\",\"totalAggregationType\":\"SUM\"},\"USER_ORGUNIT\":{\"organisationUnits\":[\"ImspTQPwCqd\"]},\"A03MvHHogjR\":{\"uid\":\"A03MvHHogjR\",\"name\":\"Birth\",\"description\":\"Birth of the baby\"},\"ouname\":{\"dimensionType\":\"ORGANISATION_UNIT\",\"name\":\"Organisation Unit Name\"}},\"dimensions\":{\"zDhUuAYrxNC\":[],\"lw1SqmMlnfh\":[],\"Qo571yj6Zcn\":[],\"DODgdr5Oo2v\":[],\"iESIqZ0R0R0\":[],\"n9nUvfpTsxQ\":[],\"kyIzQsj96BD\":[],\"xs8A6tQJY0s\":[],\"A4xFHyieXys\":[],\"OvY4VVhSDeJ\":[],\"RG7uGl4w5Jq\":[],\"spFvx9FndA4\":[],\"GUOBQt5K2WI\":[],\"Agywv2JGwuq\":[],\"lZGmxYbs97q\":[],\"VqEFza8wbwA\":[],\"ciq2USN94oJ\":[\"wfkKVdPBzho\",\"Yjte6foKMny\"],\"ou\":[\"ImspTQPwCqd\"],\"w75KJ2mc4zz\":[],\"KmEUg2hHEtx\":[],\"G7vUx908SwP\":[],\"o9odfev2Ty5\":[],\"FO4sWYJ64LQ\":[],\"NDXw0cluzSw\":[],\"ruQQnf6rswq\":[],\"cejWyOfXge6\":[\"rBvjJYbMCVx\",\"Mnp3oXrpAbK\"],\"P2cwLGskgxn\":[],\"gHGyrwKPzej\":[],\"pe\":[],\"VHfUeXpawmE\":[],\"AuPLng5hLbE\":[],\"ZcBPrXKahq2\":[],\"H9IlTX2X6SL\":[]}}";
String actualMetaData = new JSONObject((Map) response.extract("metaData")).toString();
assertEquals(expectedMetaData, actualMetaData, false);

// Assert headers.
validateHeader(
response, 0, "ouname", "Organisation unit name", "TEXT", "java.lang.String", false, true);
validateHeader(
response, 1, "gHGyrwKPzej", "Birth date", "DATE", "java.time.LocalDate", false, true);
response, 1, "w75KJ2mc4zz", "First name", "TEXT", "java.lang.String", false, true);
validateHeader(
response, 2, "ciq2USN94oJ", "Civil status", "TEXT", "java.lang.String", false, true);
response, 2, "zDhUuAYrxNC", "Last name", "TEXT", "java.lang.String", false, true);
validateHeader(
response,
3,
Expand All @@ -300,26 +300,38 @@ public void sortByEnrollmentOuAsc() throws JSONException {
true);

// Assert rows.
validateRow(response, 0, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 1, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 2, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 3, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 4, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 5, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 6, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 7, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 8, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 9, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 10, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 11, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 12, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 13, List.of(" Panderu MCHP", "", "", " Panderu MCHP"));
validateRow(response, 14, List.of("Adonkia CHP", "", "", "Adonkia CHP"));
validateRow(response, 15, List.of("Adonkia CHP", "", "", "Adonkia CHP"));
validateRow(response, 16, List.of("Adonkia CHP", "", "", "Adonkia CHP"));
validateRow(response, 17, List.of("Adonkia CHP", "", "", "Adonkia CHP"));
validateRow(response, 18, List.of("Adonkia CHP", "", "", "Adonkia CHP"));
validateRow(response, 19, List.of("Adonkia CHP", "", "", "Adonkia CHP"));
validateRow(
response,
0,
List.of(
"Praise Foundation CHC",
"Beverly",
"Armstrong",
"Praise Foundation CHC",
"2015-08-06 21:20:47.477"));
validateRow(
response,
1,
List.of(
"Praise Foundation CHC",
"Mark",
"Long",
"Praise Foundation CHC",
"2015-08-06 21:20:50.688"));
validateRow(
response,
2,
List.of(
"Praise Foundation CHC",
"Evelyn",
"Smith",
"Praise Foundation CHC",
"2015-08-06 21:20:50.693"));

validateRow( // last row
response,
19,
List.of("Bucksal Clinic", "Jeremy", "Graham", "Bucksal Clinic", "2015-08-06 21:20:49.387"));
}

@Test
Expand Down

0 comments on commit 5d70b2b

Please sign in to comment.