use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testNoCategoryOptionComboSet.
@Test
void testNoCategoryOptionComboSet() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events_cant-find-cat-option-combo-set.json");
trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1117))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method setUpTest.
@Override
protected void setUpTest() throws IOException {
renderService = _renderService;
userService = _userService;
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("tracker/tracker_basic_metadata.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle);
assertFalse(validationReport.hasErrorReports());
ObjectBundleCommitReport commit = objectBundleService.commit(bundle);
assertFalse(commit.hasErrorReports());
TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/enrollments_te_te-data.json");
User user = userService.getUser(ADMIN_USER_UID);
injectSecurityContext(user);
trackerImportParams.setUser(user);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
trackerImportParams = renderService.fromJson(new ClassPathResource("tracker/validations/enrollments_te_enrollments-data.json").getInputStream(), TrackerImportParams.class);
trackerImportParams.setUser(user);
trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testNoCategoryOption.
@Test
void testNoCategoryOption() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events_cant-find-cat-option.json");
trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1116))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class TeTaValidationTest method testEncryptedAttrFail.
@Test
void testEncryptedAttrFail() throws IOException {
setUpMetadata("tracker/validations/te-program_with_tea_encryption_metadata.json");
TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_encryption_data.json");
H2DhisConfigurationProvider dhisConfigurationProvider = (H2DhisConfigurationProvider) this.dhisConfigurationProvider;
dhisConfigurationProvider.setEncryptionStatus(EncryptionStatus.MISSING_ENCRYPTION_PASSWORD);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1112))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class TeTaValidationTest method testNoFileRef.
@Test
void testNoFileRef() throws IOException {
setUpMetadata("tracker/validations/te-program_with_tea_fileresource_metadata.json");
TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_fileresource_data.json");
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1084))));
List<TrackedEntityInstance> trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
assertEquals(0, trackedEntityInstances.size());
}
Aggregations