use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EnrollmentAttrValidationTest method initTest.
@Override
protected void initTest() throws IOException {
setUpMetadata("tracker/tracker_basic_metadata_mandatory_attr.json");
TrackerImportParams trackerBundleParams = fromJson("tracker/validations/enrollments_te_te-data_2.json");
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
manager.flush();
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EnrollmentSecurityImportValidationTest method testUserHasNoAccessToProgramTeiType.
@Test
void testUserHasNoAccessToProgramTeiType() throws IOException {
clearSecurityContext();
setupMetadata();
programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
programA.setTrackedEntityType(trackedEntityType);
manager.update(programA);
manager.flush();
User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
injectSecurityContext(user);
TrackerImportParams params = createBundleFromJson("tracker/validations/enrollments_program-teitype-missmatch.json");
params.setUser(user);
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1104))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EnrollmentSecurityImportValidationTest 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 trackerBundleParams = createBundleFromJson("tracker/validations/enrollments_te_te-data.json");
User user = userService.getUser(ADMIN_USER_UID);
trackerBundleParams.setUserId(user.getUid());
injectSecurityContext(user);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
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 EnrollmentImportValidationTest method testAttributesOk.
@Test
void testAttributesOk() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/enrollments_te_attr-data.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(1, trackerImportReport.getBundleReport().getTypeReportMap().get(TrackerType.ENROLLMENT).getObjectReportMap().values().size());
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1019))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EnrollmentImportValidationTest method testEnrollmentValidationOkAll.
@Test
void testEnrollmentValidationOkAll() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/enrollments_te_enrollments-data.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
}
Aggregations