Search in sources :

Example 66 with TrackerImportParams

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

the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedEnrollment.

@Test
void testStatsCountForOneCreatedEnrollment() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
    TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportEnrollmentReport);
    assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
    assertTrue(trackerImportEnrollmentReport.getValidationReport().getErrors().isEmpty());
    assertEquals(1, trackerImportEnrollmentReport.getStats().getCreated());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getUpdated());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getIgnored());
    assertEquals(0, trackerImportEnrollmentReport.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)

Example 67 with TrackerImportParams

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

the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedEvent.

@Test
void testStatsCountForOneCreatedEvent() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_event.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    TrackerImportReport trackerImportEventReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportEventReport);
    assertEquals(TrackerStatus.OK, trackerImportEventReport.getStatus());
    assertTrue(trackerImportEventReport.getValidationReport().getErrors().isEmpty());
    assertEquals(1, trackerImportEventReport.getStats().getCreated());
    assertEquals(0, trackerImportEventReport.getStats().getUpdated());
    assertEquals(0, trackerImportEventReport.getStats().getIgnored());
    assertEquals(0, trackerImportEventReport.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)

Example 68 with TrackerImportParams

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

the class ReportSummaryIntegrationTest method testStatsCountForOneUpdateEnrollmentAndOneCreatedEnrollment.

@Test
void testStatsCountForOneUpdateEnrollmentAndOneCreatedEnrollment() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/one_update_tei_and_one_new_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/one_update_enrollment_and_one_new_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
    TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportEnrollmentReport);
    assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
    assertTrue(trackerImportEnrollmentReport.getValidationReport().getErrors().isEmpty());
    assertEquals(1, trackerImportEnrollmentReport.getStats().getCreated());
    assertEquals(1, trackerImportEnrollmentReport.getStats().getUpdated());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getIgnored());
    assertEquals(0, trackerImportEnrollmentReport.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)

Example 69 with TrackerImportParams

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

the class ReportSummaryIntegrationTest method testStatsCountForOneUpdateEventAndOneNewEventAndOneInvalidEvent.

@Test
void testStatsCountForOneUpdateEventAndOneNewEventAndOneInvalidEvent() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_event.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/one_update_and_one_new_and_one_invalid_event.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setAtomicMode(AtomicMode.OBJECT);
    params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
    TrackerImportReport trackerImportEventReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportEventReport);
    assertEquals(TrackerStatus.OK, trackerImportEventReport.getStatus());
    assertEquals(1, trackerImportEventReport.getValidationReport().getErrors().size());
    assertEquals(1, trackerImportEventReport.getStats().getCreated());
    assertEquals(1, trackerImportEventReport.getStats().getUpdated());
    assertEquals(1, trackerImportEventReport.getStats().getIgnored());
    assertEquals(0, trackerImportEventReport.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)

Example 70 with TrackerImportParams

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

the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedEnrollmentAndUpdateSameEnrollment.

@Test
void testStatsCountForOneCreatedEnrollmentAndUpdateSameEnrollment() throws IOException {
    InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
    TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    trackerImportService.importTracker(params);
    inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
    TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportEnrollmentReport);
    assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
    assertTrue(trackerImportEnrollmentReport.getValidationReport().getErrors().isEmpty());
    assertEquals(1, trackerImportEnrollmentReport.getStats().getCreated());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getUpdated());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getIgnored());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getDeleted());
    inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
    params = renderService.fromJson(inputStream, TrackerImportParams.class);
    params.setUserId(userA.getUid());
    params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
    trackerImportEnrollmentReport = trackerImportService.importTracker(params);
    assertNotNull(trackerImportEnrollmentReport);
    assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
    assertTrue(trackerImportEnrollmentReport.getValidationReport().getErrors().isEmpty());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getCreated());
    assertEquals(1, trackerImportEnrollmentReport.getStats().getUpdated());
    assertEquals(0, trackerImportEnrollmentReport.getStats().getIgnored());
    assertEquals(0, trackerImportEnrollmentReport.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

TrackerImportParams (org.hisp.dhis.tracker.TrackerImportParams)163 Test (org.junit.jupiter.api.Test)142 TrackerImportReport (org.hisp.dhis.tracker.report.TrackerImportReport)105 TrackerTest (org.hisp.dhis.tracker.TrackerTest)46 User (org.hisp.dhis.user.User)26 ClassPathResource (org.springframework.core.io.ClassPathResource)23 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)21 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)17 InputStream (java.io.InputStream)16 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)11 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)10 List (java.util.List)9 TrackerPreheat (org.hisp.dhis.tracker.preheat.TrackerPreheat)9 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)8 Event (org.hisp.dhis.tracker.domain.Event)7 Pair (org.apache.commons.lang3.tuple.Pair)6 ProgramInstance (org.hisp.dhis.program.ProgramInstance)6 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)6 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 Program (org.hisp.dhis.program.Program)5