use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueStoredByIsValid.
@Test
void testCheckDataValueStoredByIsValid() {
DataValue dataValue = createRandomDataValue();
char[] chars = new char[300];
Arrays.fill(chars, 'x');
String storedBy = new String(chars);
dataValue.setStoredBy(storedBy);
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7637, "Invalid storedBy: stored_by_length_greater_than_max_length", context, "stored_by_length_greater_than_max_length");
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueStrictOrgUnits.
@Test
void testCheckDataValueStrictOrgUnits() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).strictOrgUnits(true).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7636, "Data element: `<object2>` must be assigned through data sets to organisation unit: `<object1>`", context, dataValue.getOrgUnit(), dataValue.getDataElement());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testCheckDataValueNotAlreadyApproved.
@Test
void testCheckDataValueNotAlreadyApproved() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).build();
DataSetContext dataSetContext = createMinimalDataSetContext(createEmptyDataValueSet()).build();
DataApprovalWorkflow workflow = new DataApprovalWorkflow();
workflow.setUid(CodeGenerator.generateUid());
dataSetContext.getDataSet().setWorkflow(workflow);
ImportContext context = createMinimalImportContext(valueContext).forceDataInput(false).build();
final String workflowPeriodAoc = workflow.getUid() + valueContext.getPeriod().getUid() + valueContext.getAttrOptionCombo().getUid();
String key = valueContext.getOrgUnit().getUid() + workflowPeriodAoc;
// already approved
context.getApprovalMap().put(key, true);
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7642, "Data is already approved for data set: `<object4>` period: `<object2>` organisation unit: `<object1>` attribute option combo: `<object3>`", context, dataValue.getOrgUnit(), dataValue.getPeriod(), dataValue.getAttributeOptionCombo(), dataSetContext.getDataSet().getUid());
}
use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext 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.DataValueContext 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());
}
Aggregations