Skip to content

Commit

Permalink
feat: Map DE to name in test [DHIS2-18871]
Browse files Browse the repository at this point in the history
  • Loading branch information
muilpp committed Jan 21, 2025
1 parent 320dde8 commit fd9be7a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@
},
"name": "test-dataelement1",
"shortName": "test-dataelement1",
"formName": "test-dataelement1",
"user": {
"id": "tTgjgobT1oS"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,24 @@ void shouldSortChangeLogsByNameWhenOrderingByChangeAndDataElementDoesNotHaveForm

updateDataValues(event, "DATAEL00001", "value00002", "value00003");

List<EventChangeLog> changeLogs =
List<String> changeLogs =
eventChangeLogService
.getEventChangeLog(UID.of("pTzf9KYMk72"), params, defaultPageParams)
.getItems();
.getItems()
.stream()
.map(this::getDisplayName)
.toList();

assertNumberOfChanges(7, changeLogs);
assertAll(
() -> assertDataElementCreate("DATAEL00005", "option1", changeLogs.get(0)),
() -> assertDataElementCreate("DATAEL00006", "88", changeLogs.get(1)),
() -> assertDataElementUpdate("DATAEL00001", "value00002", "value00003", changeLogs.get(2)),
() -> assertDataElementUpdate("DATAEL00001", "value00001", "value00002", changeLogs.get(3)),
() -> assertDataElementCreate("DATAEL00001", "value00001", changeLogs.get(4)),
() -> assertFieldCreate("scheduledAt", "2019-01-28 12:32:38.100", changeLogs.get(5)),
() -> assertFieldCreate("occurredAt", "2019-01-25 12:10:38.100", changeLogs.get(6)));
assertEquals(
List.of(
"with-option-set",
"test-dataelement6",
"test-dataelement1",
"test-dataelement1",
"test-dataelement1",
"scheduledAt",
"occurredAt"),
changeLogs);
}

@Test
Expand Down Expand Up @@ -499,4 +503,14 @@ private void updateDataValues(Event event, String dataElementUid, String... valu
private String getFirstDataElement(Event event) {
return event.getEventDataValues().iterator().next().getDataElement();
}

private String getDisplayName(EventChangeLog cl) {
if (cl.getEventField() != null) {
return cl.getEventField();
} else if (cl.getDataElement().getFormName() != null) {
return cl.getDataElement().getFormName();
} else {
return cl.getDataElement().getName();
}
}
}

0 comments on commit fd9be7a

Please sign in to comment.