Search in sources :

Example 66 with TrackerImportReport

use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.

the class ProgramRuleIntegrationTest method testImportEnrollmentSuccessWithWarningRaised.

@Test
void testImportEnrollmentSuccessWithWarningRaised() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    TrackerImportReport trackerImportTeiReport = trackerImportService.importTracker(params);
    TrackerImportParams enrollmentParams = renderService.fromJson(new ClassPathResource("tracker/single_enrollment.json").getInputStream(), TrackerImportParams.class);
    enrollmentParams.setUserId(userA.getUid());
    TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(enrollmentParams);
    assertNotNull(trackerImportTeiReport);
    assertEquals(TrackerStatus.OK, trackerImportTeiReport.getStatus());
    assertNotNull(trackerImportEnrollmentReport);
    assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
    assertEquals(1, trackerImportEnrollmentReport.getValidationReport().getWarnings().size());
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 67 with TrackerImportReport

use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.

the class AtomicModeIntegrationTest method testImportSuccessWithAtomicModeObjectIfThereIsAnErrorInOneTEI.

@Test
void testImportSuccessWithAtomicModeObjectIfThereIsAnErrorInOneTEI() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/one_valid_tei_and_one_invalid.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setAtomicMode(AtomicMode.OBJECT);
    TrackerImportReport trackerImportTeiReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportTeiReport);
    assertEquals(TrackerStatus.OK, trackerImportTeiReport.getStatus());
    assertEquals(1, trackerImportTeiReport.getValidationReport().getErrors().size());
    assertNotNull(trackedEntityInstanceService.getTrackedEntityInstance("VALIDTEIAAA"));
    assertNull(trackedEntityInstanceService.getTrackedEntityInstance("INVALIDTEIA"));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 68 with TrackerImportReport

use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.

the class RelationshipImportTest method successUpdateRelationships.

@Test
void successUpdateRelationships() throws IOException {
    TrackerImportParams trackerImportParams = fromJson("tracker/relationships.json");
    trackerImportService.importTracker(trackerImportParams);
    trackerImportParams = fromJson("tracker/relationshipToUpdate.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertThat(trackerImportReport.getStatus(), is(TrackerStatus.OK));
    assertThat(trackerImportReport.getStats().getCreated(), is(0));
    assertThat(trackerImportReport.getStats().getIgnored(), is(1));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Example 69 with TrackerImportReport

use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.

the class RelationshipImportTest method successImportingRelationships.

@Test
void successImportingRelationships() throws IOException {
    TrackerImportParams trackerImportParams = fromJson("tracker/relationships.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertThat(trackerImportReport.getStatus(), is(TrackerStatus.OK));
    assertThat(trackerImportReport.getStats().getCreated(), is(2));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Example 70 with TrackerImportReport

use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.

the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedTEI.

@Test
void testStatsCountForOneCreatedTEI() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setAtomicMode(AtomicMode.OBJECT);
    TrackerImportReport trackerImportTeiReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportTeiReport);
    assertEquals(TrackerStatus.OK, trackerImportTeiReport.getStatus());
    assertTrue(trackerImportTeiReport.getValidationReport().getErrors().isEmpty());
    assertEquals(1, trackerImportTeiReport.getStats().getCreated());
    assertEquals(0, trackerImportTeiReport.getStats().getUpdated());
    assertEquals(0, trackerImportTeiReport.getStats().getIgnored());
    assertEquals(0, trackerImportTeiReport.getStats().getDeleted());
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) 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