Search in sources :

Example 71 with DataValueSet

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);
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) DhisTest(org.hisp.dhis.DhisTest) Test(org.junit.jupiter.api.Test)

Example 72 with DataValueSet

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);
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) DhisTest(org.hisp.dhis.DhisTest) Test(org.junit.jupiter.api.Test)

Example 73 with DataValueSet

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);
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) DhisTest(org.hisp.dhis.DhisTest) Test(org.junit.jupiter.api.Test)

Example 74 with DataValueSet

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);
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) DhisTest(org.hisp.dhis.DhisTest) Test(org.junit.jupiter.api.Test)

Example 75 with DataValueSet

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

Aggregations

Test (org.junit.jupiter.api.Test)63 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)56 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)41 ClassPathResource (org.springframework.core.io.ClassPathResource)39 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)24 DataValue (org.hisp.dhis.datavalue.DataValue)21 DhisTest (org.hisp.dhis.DhisTest)12 DataValueSet (org.hisp.dhis.dxf2.datavalueset.DataValueSet)9 DataValueAudit (org.hisp.dhis.datavalue.DataValueAudit)8 DataSetContext (org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext)8 DataSet (org.hisp.dhis.dataset.DataSet)6 Period (org.hisp.dhis.period.Period)6 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)5 ImportCount (org.hisp.dhis.dxf2.importsummary.ImportCount)5 ListGrid (org.hisp.dhis.system.grid.ListGrid)5 IdScheme (org.hisp.dhis.common.IdScheme)4 DataElement (org.hisp.dhis.dataelement.DataElement)4 IdentifiableObjectCallable (org.hisp.dhis.system.callable.IdentifiableObjectCallable)4 Date (java.util.Date)3 List (java.util.List)3