Search in sources :

Example 1 with TrackerImportParams

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

the class EnrollmentAttrValidationTest method testAttributesMissingUid.

@Test
void testAttributesMissingUid() throws IOException {
    TrackerImportParams params = createBundleFromJson("tracker/validations/enrollments_te_attr-missing-uuid.json");
    params.setImportStrategy(TrackerImportStrategy.CREATE);
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
    assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1075))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 2 with TrackerImportParams

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

the class EnrollmentAttrValidationTest method testAttributesUniquenessAlreadyInDB.

@Test
void testAttributesUniquenessAlreadyInDB() throws IOException {
    TrackerImportParams params = fromJson("tracker/validations/enrollments_te_te-data_3.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
    assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
    manager.flush();
    manager.clear();
    params = createBundleFromJson("tracker/validations/enrollments_te_unique_attr_same_tei.json");
    params.setImportStrategy(TrackerImportStrategy.CREATE);
    trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
    manager.flush();
    manager.clear();
    params = createBundleFromJson("tracker/validations/enrollments_te_unique_attr_in_db.json");
    params.setImportStrategy(TrackerImportStrategy.CREATE);
    trackerImportReport = trackerImportService.importTracker(params);
    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 3 with TrackerImportParams

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

the class EnrollmentAttrValidationTest method testAttributesOnlyProgramAttrAllowed.

@Test
void testAttributesOnlyProgramAttrAllowed() throws IOException {
    TrackerImportParams params = createBundleFromJson("tracker/validations/enrollments_te_attr-only-program-attr.json");
    params.setImportStrategy(TrackerImportStrategy.CREATE);
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
    assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1019))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) Test(org.junit.jupiter.api.Test)

Example 4 with TrackerImportParams

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

the class EnrollmentAttrValidationTest method testAttributesMissingTeA.

// TODO: Fails with: (need to figure out how to force deletion here first)
// * ERROR 22:47:50,353 Failed to invoke method deleteTrackedEntityAttribute
// on DeletionHandler 'ProgramDeletionHandler' (DefaultDeletionManager.java
// [main])
@Test
@Disabled("Delete not impl.")
void testAttributesMissingTeA() throws IOException {
    TrackedEntityAttribute sTJvSLN7Kcb = trackedEntityAttributeService.getTrackedEntityAttribute("sTJvSLN7Kcb");
    trackedEntityAttributeService.deleteTrackedEntityAttribute(sTJvSLN7Kcb);
    TrackerImportParams params = createBundleFromJson("tracker/validations/enrollments_te_attr-data.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
    assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1006))));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 5 with TrackerImportParams

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

the class EnrollmentAttrValidationTest method testAttributesUniquenessInDifferentTeis.

@Test
void testAttributesUniquenessInDifferentTeis() throws IOException {
    TrackerImportParams params = fromJson("tracker/validations/enrollments_te_te-data_3.json");
    TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
    assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
    manager.flush();
    manager.clear();
    params = createBundleFromJson("tracker/validations/enrollments_te_unique_attr.json");
    params.setImportStrategy(TrackerImportStrategy.CREATE);
    trackerImportReport = trackerImportService.importTracker(params);
    assertEquals(2, 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)

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