use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext 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());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext 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.DataValueContext 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.DataValueContext 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.DataValueContext 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