use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class CsvMetadataImportTest method testOrgUnitImport.
@Test
void testOrgUnitImport() throws Exception {
ImportReport importReport = runImport("metadata/organisationUnits.csv", CsvImportClass.ORGANISATION_UNIT, metadata -> assertEquals(6, metadata.getOrganisationUnits().size()));
assertEquals(6, importReport.getStats().getCreated());
assertEquals(6, organisationUnitService.getAllOrganisationUnits().size());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class CsvMetadataImportTest method testOptionSetImport.
@Test
void testOptionSetImport() throws Exception {
ImportReport importReport = runImport("metadata/optionSets.csv", CsvImportClass.OPTION_SET, metadata -> {
assertEquals(4, metadata.getOptionSets().size());
assertEquals(3, metadata.getOptionSets().get(0).getOptions().size());
assertEquals(3, metadata.getOptionSets().get(1).getOptions().size());
assertEquals(3, metadata.getOptionSets().get(2).getOptions().size());
assertEquals(3, metadata.getOptionSets().get(3).getOptions().size());
});
assertEquals(16, importReport.getStats().getCreated());
List<OptionSet> optionSets = new ArrayList<>(optionService.getAllOptionSets());
assertEquals(4, optionSets.size());
assertEquals(3, optionSets.get(0).getOptions().size());
assertEquals(3, optionSets.get(1).getOptions().size());
assertEquals(3, optionSets.get(2).getOptions().size());
assertEquals(3, optionSets.get(3).getOptions().size());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataRetryContextTest method testIfSummaryIsNotNull.
@Test
void testIfSummaryIsNotNull() {
MetadataSyncSummary testSummary = new MetadataSyncSummary();
ImportReport importReport = new ImportReport();
importReport.setStatus(Status.ERROR);
testSummary.setImportReport(importReport);
metadataRetryContext.updateRetryContext(testKey, testMessage, mockVersion, testSummary);
verify(retryContext).setAttribute(testKey, testMessage);
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class TrackedEntityTypeValidationTest method shouldFailMissingTrackedEntityAttribute.
@Test
void shouldFailMissingTrackedEntityAttribute() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/simple_metadata.json").getInputStream(), RenderFormat.JSON);
MetadataImportParams importParams = new MetadataImportParams();
importParams.setImportMode(ObjectBundleMode.COMMIT);
importParams.setImportStrategy(ImportStrategy.CREATE);
importParams.setObjects(metadata);
ImportReport report = importService.importMetadata(importParams);
assertEquals(Status.OK, report.getStatus());
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> importMetadata = renderService.fromMetadata(new ClassPathResource("dxf2/import/te_type_missing_tea.json").getInputStream(), RenderFormat.JSON);
MetadataImportParams importParamsFail = new MetadataImportParams();
importParamsFail.setImportMode(ObjectBundleMode.COMMIT);
importParamsFail.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE);
importParamsFail.setObjects(importMetadata);
ImportReport importReport = importService.importMetadata(importParamsFail);
assertEquals(Status.ERROR, importReport.getStatus());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class TrackedEntityTypeValidationTest method shouldSuccessTrackedEntityAttributeExists.
@Test
void shouldSuccessTrackedEntityAttributeExists() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/simple_metadata.json").getInputStream(), RenderFormat.JSON);
MetadataImportParams importParams = new MetadataImportParams();
importParams.setImportMode(ObjectBundleMode.COMMIT);
importParams.setImportStrategy(ImportStrategy.CREATE);
importParams.setObjects(metadata);
ImportReport report = importService.importMetadata(importParams);
assertEquals(Status.OK, report.getStatus());
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> importMetadata = renderService.fromMetadata(new ClassPathResource("dxf2/import/te_type_tea_ok.json").getInputStream(), RenderFormat.JSON);
MetadataImportParams importParamsFail = new MetadataImportParams();
importParamsFail.setImportMode(ObjectBundleMode.COMMIT);
importParamsFail.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE);
importParamsFail.setObjects(importMetadata);
ImportReport importReport = importService.importMetadata(importParamsFail);
assertEquals(Status.OK, importReport.getStatus());
}
Aggregations