use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext 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.DataValueContext 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);
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValuePeriodExists.
@Test
void testValidateDataValuePeriodExists() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).period(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7611, "Period not valid: `<object1>`", context, dataValue.getPeriod());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValueCategoryOptionComboExists.
@Test
void testValidateDataValueCategoryOptionComboExists() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).categoryOptionCombo(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7613, "Category option combo not found or not accessible for writing data: `<object1>`", context, dataValue.getCategoryOptionCombo());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValueAttrOptionComboExists.
@Test
void testValidateDataValueAttrOptionComboExists() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).attrOptionCombo(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7615, "Attribute option combo not found or not accessible for writing data: `<object1>`", context, dataValue.getAttributeOptionCombo());
}
Aggregations