use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityImportValidationTest method testTeAttrNonExistentAttr.
@Test
void testTeAttrNonExistentAttr() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/te-data_error_attr-non-existing.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(2, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1006))));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityImportValidationTest method testNoUpdateAccessOutsideSearchScopeOu.
@Test
void testNoUpdateAccessOutsideSearchScopeOu() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/te-data_with_different_ou.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(3, trackerImportReport.getStats().getCreated());
dbmsManager.clearSession();
params = createBundleFromJson("tracker/validations/te-data_with_different_ou.json");
User user = userService.getUser(USER_7);
params.setUser(user);
params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
params.setAtomicMode(AtomicMode.OBJECT);
trackerImportReport = trackerImportService.importTracker(params);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(2, trackerImportReport.getStats().getUpdated());
assertEquals(1, trackerImportReport.getStats().getIgnored());
assertThat(trackerImportReport.getValidationReport().getErrors(), IsCollectionContaining.hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1003))));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityImportValidationTest method testTeValidationOkAll.
@Test
void testTeValidationOkAll() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/te-data_with_different_ou.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityImportValidationTest method testGeoOk.
@Test
void testGeoOk() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/te-data_error_geo-ok.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityAttributeTest method testTrackedAttributePreheater.
@Test
void testTrackedAttributePreheater() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/te_with_tea_data.json");
TrackerPreheat preheat = trackerPreheatService.preheat(trackerImportParams);
assertNotNull(preheat.get(OrganisationUnit.class, "cNEZTkdAvmg"));
assertNotNull(preheat.get(TrackedEntityType.class, "KrYIdvLxkMb"));
assertNotNull(preheat.get(TrackedEntityAttribute.class, "sYn3tkL3XKa"));
assertNotNull(preheat.get(TrackedEntityAttribute.class, "TsfP85GKsU5"));
assertNotNull(preheat.get(TrackedEntityAttribute.class, "sTGqP5JNy6E"));
}
Aggregations