use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataSetExists.
/*
* Data Set validation (should the set be aborted)
*/
@Test
void testValidateDataSetExists() {
DataValueSet dataValueSet = createEmptyDataValueSet();
ImportContext context = createMinimalImportContext(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
assertTrue(validator.abortDataSetImport(dataValueSet, context, dataSetContext));
assertConflict(ErrorCode.E7600, "Data set not found or not accessible: `<object1>`", context, dataValueSet.getDataSet());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValuePeriodType.
@Test
void testCheckDataValuePeriodType() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).strictPeriods(true).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7632, "Period type of period: `<object1>` not valid for data element: `<object2>`", context, dataValue.getPeriod(), dataValue.getDataElement());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValuePeriodWithinAttrOptionComboRange.
@Test
void testCheckDataValuePeriodWithinAttrOptionComboRange() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
String key = valueContext.getAttrOptionCombo().getUid() + valueContext.getDataElement().getUid();
context.getAttrOptionComboDateRangeMap().put(key, new DateRange(new Date(), null));
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7638, "Period: `<object1>` is not within date range of attribute option combo: `<object2>`", context, dataValue.getPeriod(), dataValue.getAttributeOptionCombo());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValueCommentIsValid.
@Test
void testValidateDataValueCommentIsValid() {
DataValue dataValue = createRandomDataValue();
char[] chars = new char[50001];
Arrays.fill(chars, 'a');
dataValue.setComment(new String(chars));
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7620, "Invalid comment: comment_length_greater_than_max_length", context, "comment_length_greater_than_max_length");
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueOrgUnitValidForAttrOptionCombo.
@Test
void testCheckDataValueOrgUnitValidForAttrOptionCombo() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
String key = valueContext.getAttrOptionCombo().getUid() + valueContext.getOrgUnit().getUid();
context.getAttrOptionComboOrgUnitMap().put(key, false);
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7639, "Organisation unit: `<object1>` is not valid for attribute option combo: `<object2>`", context, dataValue.getOrgUnit(), dataValue.getAttributeOptionCombo());
}
Aggregations