use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext 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.DataSetContext 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.DataSetContext 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());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataSetAttrOptionComboExists.
@Test
void testValidateDataSetAttrOptionComboExists() {
when(aclService.canDataRead(any(), any())).thenReturn(true);
DataValueSet dataValueSet = new DataValueSet();
dataValueSet.setAttributeOptionCombo(CodeGenerator.generateUid());
ImportContext context = createMinimalImportContext(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
assertTrue(validator.abortDataSetImport(dataValueSet, context, dataSetContext));
assertConflict(ErrorCode.E7604, "Attribute option combo not found or not accessible: `<object1>`", context, dataValueSet.getAttributeOptionCombo(), dataValueSet.getDataSet());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueStrictAttrOptionCombos.
@Test
void testCheckDataValueStrictAttrOptionCombos() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).strictAttrOptionCombos(true).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7635, "Attribute option combo: `<object1>` must be part of category combo of data sets of data element: `<object2>`", context, dataValue.getAttributeOptionCombo(), dataValue.getDataElement());
}
Aggregations