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 2e71592e11fb..cccdc7053c59 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 @@ -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( 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 4db3dd2d5ead..a4c87d0ef9ad 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 @@ -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 = @@ -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) {