use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueAttrOptionCombo.
@Test
void testCheckDataValueAttrOptionCombo() {
DataValue dataValue = createRandomDataValue();
dataValue.setAttributeOptionCombo(null);
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).requireAttrOptionCombo(true).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7631, "Attribute option combo is required but is not specified", context);
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueStrictCategoryOptionCombos.
@Test
void testCheckDataValueStrictCategoryOptionCombos() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
valueContext.getDataElement().setCategoryCombo(new CategoryCombo());
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).strictCategoryOptionCombos(true).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7634, "Category option combo: `<object1>` must be part of category combo of data element: `<object2>`", context, dataValue.getCategoryOptionCombo(), dataValue.getDataElement());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValueDataElementExists.
/*
* Data Value validation (should the entry be skipped)
*/
@Test
void testValidateDataValueDataElementExists() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = DataValueContext.builder().build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7610, "Data element not found or not accessible: `<object1>`", context, dataValue.getDataElement());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataSetOrgUnitExists.
@Test
void testValidateDataSetOrgUnitExists() {
when(aclService.canDataRead(any(), any())).thenReturn(true);
DataValueSet dataValueSet = new DataValueSet();
dataValueSet.setOrgUnit(CodeGenerator.generateUid());
ImportContext context = createMinimalImportContext(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
assertTrue(validator.abortDataSetImport(dataValueSet, context, dataSetContext));
assertConflict(ErrorCode.E7603, "Org unit not found or not accessible: `<object1>`", context, dataValueSet.getOrgUnit(), dataValueSet.getDataSet());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueCategoryOptionCombo.
/*
* DataValue Constraints
*/
@Test
void testCheckDataValueCategoryOptionCombo() {
DataValue dataValue = createRandomDataValue();
dataValue.setCategoryOptionCombo(null);
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).requireCategoryOptionCombo(true).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7630, "Category option combo is required but is not specified", context);
}
Aggregations