Search in sources :

Example 46 with TrackerImportParams

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

the class EventImportValidationTest method testEventValidationOkAll.

@Test
void testEventValidationOkAll() throws IOException {
    TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events-data.json");
    trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
    assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
    assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 47 with TrackerImportParams

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

the class TeTaValidationTest method testUniqueFailInOrgUnit.

@Test
void testUniqueFailInOrgUnit() throws IOException {
    setUpMetadata("tracker/validations/te-program_with_tea_encryption_metadata.json");
    TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_unique_data_in_country.json");
    trackerImportService.importTracker(trackerImportParams);
    trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_unique_data_in_country.json");
    trackerImportParams.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
    trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_unique_data_in_region.json");
    trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 48 with TrackerImportParams

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

the class TeTaValidationTest method testTeaIsNull.

@Test
void testTeaIsNull() throws IOException {
    setUpMetadata("tracker/validations/te-program-with-tea-mandatory-image.json");
    TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_invalid_value_isnull.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
    assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1076))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 49 with TrackerImportParams

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

the class TeTaValidationTest method testUniqueFail.

@Test
void testUniqueFail() throws IOException {
    setUpMetadata("tracker/validations/te-program_with_tea_encryption_metadata.json");
    TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_unique_data.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_unique_data2.json");
    trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
    assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1064))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 50 with TrackerImportParams

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

the class TeTaValidationTest method testTeaMaxTextValueLength.

@Test
void testTeaMaxTextValueLength() throws IOException {
    setUpMetadata("tracker/validations/te-program_with_tea_fileresource_metadata.json");
    TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/te-program_with_tea_too_long_text_value.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
    assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
    assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1077))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) 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