Search in sources :

Example 16 with DataValueContext

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());
}
Also used : DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DataSetContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext) DataValueContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext) Test(org.junit.jupiter.api.Test)

Example 17 with DataValueContext

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);
}
Also used : DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DataSetContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext) DataValueContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext) Test(org.junit.jupiter.api.Test)

Example 18 with DataValueContext

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());
}
Also used : DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DataSetContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext) DataValueContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext) Test(org.junit.jupiter.api.Test)

Example 19 with DataValueContext

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());
}
Also used : DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DataSetContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext) DataValueContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext) Test(org.junit.jupiter.api.Test)

Example 20 with DataValueContext

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());
}
Also used : DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DataSetContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext) DataValueContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext) Test(org.junit.jupiter.api.Test)

Aggregations

DataValue (org.hisp.dhis.dxf2.datavalue.DataValue)28 DataSetContext (org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext)28 DataValueContext (org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext)28 Test (org.junit.jupiter.api.Test)28 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 DataInputPeriod (org.hisp.dhis.dataset.DataInputPeriod)2 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)2 Date (java.util.Date)1 CategoryCombo (org.hisp.dhis.category.CategoryCombo)1 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)1 DateRange (org.hisp.dhis.common.DateRange)1 DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)1 DataElement (org.hisp.dhis.dataelement.DataElement)1 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)1 OptionSet (org.hisp.dhis.option.OptionSet)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Period (org.hisp.dhis.period.Period)1 User (org.hisp.dhis.user.User)1