use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testImportValuesXml.
/**
* Import 12 data values.
*/
@Test
void testImportValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetB.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(12, 0, 0, summary);
assertDataValuesCount(12);
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testImportAddAndReverseDeletedValuesXml.
/**
* Import 12 data values where 4 are marked as deleted. Then import 12 data
* values which reverse deletion of the 4 values, update 4 values and add 4
* values.
*/
@Test
void testImportAddAndReverseDeletedValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetBDeleted.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertEquals(12, summary.getImportCount().getImported());
assertDataValuesCount(8);
// Reverse deletion and update
in = readFile("datavalueset/dataValueSetBNew.xml");
summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(8, 4, 0, summary);
assertDataValuesCount(16);
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testImportDeleteValuesXml.
/**
* Import 3 data values, then delete 3 data values.
*/
@Test
void testImportDeleteValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetA.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(3, 0, 0, summary);
assertDataValuesCount(3);
// Delete values
in = readFile("datavalueset/dataValueSetADeleted.xml");
summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(0, 0, 3, summary);
assertDataValuesCount(0);
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testImportAndDeleteValuesXml.
/**
* Import 12 data values. Then import 12 values where 4 are marked as
* deleted, 6 are updates and 2 are new.
*/
@Test
void testImportAndDeleteValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetB.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertEquals(12, summary.getImportCount().getImported());
assertDataValuesCount(12);
// Delete 4 values, add 2 values
in = readFile("datavalueset/dataValueSetBNewDeleted.xml");
summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(2, 6, 4, summary);
assertDataValuesCount(10);
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet 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());
}
Aggregations