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 4c5c5ddecf4b..e4f00f0a118d 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 @@ -55,7 +55,6 @@ import org.hisp.dhis.dxf2.importsummary.ImportStatus; import org.hisp.dhis.dxf2.importsummary.ImportSummary; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.security.acl.AclService; @@ -82,8 +81,6 @@ public class DataValueSetImportValidator { private final DataValueService dataValueService; - private final OrganisationUnitService organisationUnitService; - /** Validation on the {@link DataSet} level */ interface DataSetValidation { void validate(DataValueSet dataValueSet, ImportContext context, DataSetContext dataSetContext); @@ -649,8 +646,7 @@ private void checkDataValueOrgUnitValidForAttrOptionCombo( private boolean isOrgUnitValidForAttrOptionCombo(DataValueContext valueContext) { Set aocOrgUnits = valueContext.getAttrOptionCombo().getOrganisationUnits(); - return aocOrgUnits == null - || organisationUnitService.isDescendant(valueContext.getOrgUnit(), aocOrgUnits); + return aocOrgUnits == null || valueContext.getOrgUnit().isDescendant(aocOrgUnits); } private static void checkDataValueTargetDataSets( 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 0ce0103f9153..082724c49a0b 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 @@ -73,7 +73,6 @@ import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.period.PeriodTypeEnum; @@ -103,8 +102,6 @@ class DataValueSetImportValidatorTest { private DataValueSetImportValidator validator; - private OrganisationUnitService organisationUnitService; - private final CategoryCombo defaultCombo = new CategoryCombo(); @BeforeEach @@ -114,17 +111,11 @@ void setUp() { lockExceptionStore = mock(LockExceptionStore.class); approvalService = mock(DataApprovalService.class); dataValueService = mock(DataValueService.class); - organisationUnitService = mock(OrganisationUnitService.class); i18n = mock(I18n.class); validator = new DataValueSetImportValidator( - aclService, - accessManager, - lockExceptionStore, - approvalService, - dataValueService, - organisationUnitService); + aclService, accessManager, lockExceptionStore, approvalService, dataValueService); validator.init(); setupUserCanWriteCategoryOptions(true); when(i18n.getString(anyString())) @@ -304,12 +295,6 @@ void testValidateDataValueAttrOptionComboAccess() { @Test void testValidateDataValueOrgUnitInUserHierarchy() { - when(organisationUnitService.isDescendant(any(OrganisationUnit.class), any(Set.class))) - .thenReturn(false); - when(organisationUnitService.isDescendant( - any(OrganisationUnit.class), any(OrganisationUnit.class))) - .thenReturn(false); - DataValue dataValue = createRandomDataValue(); DataValueContext valueContext = createDataValueContext(dataValue).build(); DataSetContext dataSetContext = createMinimalDataSetContext().build();