Search in sources :

Example 96 with TrackerImportReport

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))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 97 with TrackerImportReport

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());
}
Also used : ObjectBundleParams(org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams) TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) ObjectBundleCommitReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleCommitReport) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) ObjectBundle(org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle) User(org.hisp.dhis.user.User) ObjectBundleValidationReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport) List(java.util.List) ClassPathResource(org.springframework.core.io.ClassPathResource) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject)

Example 98 with TrackerImportReport

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))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 99 with TrackerImportReport

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))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) H2DhisConfigurationProvider(org.hisp.dhis.config.H2DhisConfigurationProvider) Test(org.junit.jupiter.api.Test)

Example 100 with TrackerImportReport

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());
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) Test(org.junit.jupiter.api.Test)

Aggregations

TrackerImportReport (org.hisp.dhis.tracker.report.TrackerImportReport)114 TrackerImportParams (org.hisp.dhis.tracker.TrackerImportParams)105 Test (org.junit.jupiter.api.Test)99 User (org.hisp.dhis.user.User)23 TrackerTest (org.hisp.dhis.tracker.TrackerTest)21 ClassPathResource (org.springframework.core.io.ClassPathResource)20 InputStream (java.io.InputStream)17 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)15 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)9 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)8 ProgramInstance (org.hisp.dhis.program.ProgramInstance)5 Date (java.util.Date)4 List (java.util.List)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 Program (org.hisp.dhis.program.Program)4 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)3 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)3 TrackerValidationReport (org.hisp.dhis.tracker.report.TrackerValidationReport)3 TrackerImportReportRequest (org.hisp.dhis.webapi.controller.tracker.TrackerImportReportRequest)3 ResponseEntity (org.springframework.http.ResponseEntity)3