Skip to content

Commit

Permalink
fix: Remove unnecessary calls to the DB during DataValueSet import [D…
Browse files Browse the repository at this point in the history
…HIS2-16138] (#15639)

* fix: Remove calls to DB during DataValueSet import [DHIS2-16138]

* fix: Update tests to reflect the removal of DB interaction [DHIS2-16138]
  • Loading branch information
david-mackessy authored Nov 10, 2023
1 parent dae3308 commit 40cf7ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ private void validateDataValueOrgUnitInUserHierarchy(
.getOrgUnitInHierarchyMap()
.get(
valueContext.getOrgUnit().getUid(),
() ->
organisationUnitService.isDescendant(
valueContext.getOrgUnit(), context.getCurrentOrgUnits()));
() -> valueContext.getOrgUnit().isDescendant(context.getCurrentOrgUnits()));

if (!inUserHierarchy) {
context.addConflict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ void setUp() {
approvalService = mock(DataApprovalService.class);
dataValueService = mock(DataValueService.class);
organisationUnitService = mock(OrganisationUnitService.class);
when(organisationUnitService.isDescendant(any(OrganisationUnit.class), any(Set.class)))
.thenReturn(true);
when(organisationUnitService.isDescendant(
any(OrganisationUnit.class), any(OrganisationUnit.class)))
.thenReturn(true);

i18n = mock(I18n.class);
validator =
Expand Down Expand Up @@ -899,6 +894,9 @@ private DataValueContextBuilder createDataValueContext(DataValue dataValue) {
if (ouId != null) {
OrganisationUnit ou = new OrganisationUnit();
ou.setUid(ouId);
// we set the path here just for the tests. This is usually done by the persistence layer
// but there is no interaction with that in these tests.
ou.setPath(ou.getPath());
builder.orgUnit(ou);
}
if (coId != null) {
Expand Down

0 comments on commit 40cf7ad

Please sign in to comment.