use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method createMinimalDataSetContext.
private DataSetContextBuilder createMinimalDataSetContext(DataValueSet dataValueSet) {
DataSetContextBuilder builder = DataSetContext.builder();
if (dataValueSet != null) {
String dsId = dataValueSet.getDataSet();
if (dsId != null) {
DataSet ds = new DataSet();
ds.setUid(dsId);
builder.dataSet(ds);
}
}
return builder;
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesInvalidAttributeOptionComboDates.
@Test
void testImportDataValuesInvalidAttributeOptionComboDates() throws Exception {
clearSecurityContext();
categoryOptionA.setStartDate(peB.getStartDate());
categoryOptionA.setEndDate(peB.getEndDate());
categoryService.updateCategoryOption(categoryOptionA);
in = new ClassPathResource("datavalueset/dataValueSetH.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertEquals(2, summary.getConflictCount(), summary.getConflictsDescription());
assertEquals(1, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(2, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.WARNING, summary.getStatus());
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(1, dataValues.size());
assertTrue(dataValues.contains(new DataValue(deB, peB, ouB, ocDef, ocA)));
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesCsvWithoutHeader.
@Test
void testImportDataValuesCsvWithoutHeader() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetBNoHeader.csv").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetCsv(in, new ImportOptions().setFirstRowIsHeader(false), null);
assertEquals(12, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertImportDataValues(summary);
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportValueCategoryOptionWriteOk.
/**
* User has data write access for DataSet and CategoryOption
*
* @throws IOException
*/
@Test
void testImportValueCategoryOptionWriteOk() throws IOException {
enableDataSharing(user, dsA, AccessStringHelper.DATA_READ_WRITE);
enableDataSharing(user, categoryOptionA, AccessStringHelper.DATA_READ_WRITE);
enableDataSharing(user, categoryOptionB, AccessStringHelper.DATA_READ_WRITE);
in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertNotNull(summary);
assertNotNull(summary.getImportCount());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportValueCatComboOk.
/**
* User has data write access for DataSet and also categoryOptions Expect
* success
*
* @throws IOException
*/
@Test
void testImportValueCatComboOk() throws IOException {
enableDataSharing(user, dsA, AccessStringHelper.DATA_READ_WRITE);
enableDataSharing(user, categoryOptionA, AccessStringHelper.DATA_WRITE);
enableDataSharing(user, categoryOptionB, AccessStringHelper.DATA_WRITE);
in = new ClassPathResource("datavalueset/dataValueSetACatCombo.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertNotNull(summary);
assertNotNull(summary.getImportCount());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
}
Aggregations