diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidator.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidator.java index 39dcaf5a5fb9..4c5c5ddecf4b 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidator.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidator.java @@ -355,9 +355,7 @@ private void validateDataValueOrgUnitInUserHierarchy( .getOrgUnitInHierarchyMap() .get( valueContext.getOrgUnit().getUid(), - () -> - organisationUnitService.isDescendant( - valueContext.getOrgUnit(), context.getCurrentOrgUnits())); + () -> valueContext.getOrgUnit().isDescendant(context.getCurrentOrgUnits())); if (!inUserHierarchy) { context.addConflict( diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidatorTest.java b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidatorTest.java index 381b0ddcda2c..0ce0103f9153 100644 --- a/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidatorTest.java +++ b/dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetImportValidatorTest.java @@ -115,11 +115,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 = @@ -905,6 +900,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) {