Search in sources :

Example 16 with ImmutableEvent

use of org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent in project dhis2-core by dhis2.

the class AttributeOptionComboDateCheckTest method failOnCategoryOptionEndDateBeforeEventDate.

@Test
void failOnCategoryOptionEndDateBeforeEventDate() {
    event.setEventDate("2019-05-01");
    event.setDueDate("2019-05-10");
    CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2019-04-01", false);
    mockContext(categoryOptionCombo);
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
    assertHasError(importSummary, event, "Event date 2019-05-01 is after end date 2019-04-01 for attributeOption 'test' in program 'TestProgram'");
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Example 17 with ImmutableEvent

use of org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent in project dhis2-core by dhis2.

the class AttributeOptionComboDateCheckTest method succeedBeforeOpenDaysAfterCoEndDate.

@Test
void succeedBeforeOpenDaysAfterCoEndDate() {
    event.setEventDate("2019-05-01");
    event.setDueDate("2019-05-10");
    program.setOpenDaysAfterCoEndDate(31);
    CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2019-04-01", false);
    mockContext(categoryOptionCombo);
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
    assertNoError(importSummary);
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Example 18 with ImmutableEvent

use of org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent in project dhis2-core by dhis2.

the class AttributeOptionComboDateCheckTest method failOnCategoryOptionStartDateBeforeEventDate.

@Test
void failOnCategoryOptionStartDateBeforeEventDate() {
    event.setEventDate("2019-05-01");
    event.setDueDate("2019-05-10");
    CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2020-01-01", true);
    mockContext(categoryOptionCombo);
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
    assertHasError(importSummary, event, "Event date 2019-05-01 is before start date 2020-01-01 for attributeOption 'test'");
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Example 19 with ImmutableEvent

use of org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent in project dhis2-core by dhis2.

the class EventBaseCheckTest method verifyErrorOnInvalidLastUpdatedAtClientDate.

@Test
void verifyErrorOnInvalidLastUpdatedAtClientDate() {
    event.setEvent(event.getUid());
    event.setLastUpdatedAtClient("111-12-122");
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), workContext);
    assertHasError(importSummary, event, null);
    assertHasConflict(importSummary, event, "Invalid event last updated at client date: " + event.getLastUpdatedAtClient());
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Example 20 with ImmutableEvent

use of org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent in project dhis2-core by dhis2.

the class EventBaseCheckTest method verifyNoErrorOnNonCompletedProgramInstance.

@Test
void verifyNoErrorOnNonCompletedProgramInstance() {
    event.setEvent(event.getUid());
    Map<String, ProgramInstance> programInstanceMap = new HashMap<>();
    ProgramInstance programInstance = new ProgramInstance();
    programInstanceMap.put(event.getUid(), programInstance);
    when(workContext.getProgramInstanceMap()).thenReturn(programInstanceMap);
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), workContext);
    assertNoError(importSummary);
}
Also used : HashMap(java.util.HashMap) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) ProgramInstance(org.hisp.dhis.program.ProgramInstance) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Aggregations

ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)49 ImmutableEvent (org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent)38 Test (org.junit.jupiter.api.Test)35 BaseValidationTest (org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)34 Program (org.hisp.dhis.program.Program)18 HashMap (java.util.HashMap)17 DhisConvenienceTest.createProgram (org.hisp.dhis.DhisConvenienceTest.createProgram)13 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)11 ProgramInstance (org.hisp.dhis.program.ProgramInstance)10 DataValue (org.hisp.dhis.dxf2.events.event.DataValue)9 ProgramStage (org.hisp.dhis.program.ProgramStage)8 DataElement (org.hisp.dhis.dataelement.DataElement)7 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)7 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)7 DhisConvenienceTest.createDataElement (org.hisp.dhis.DhisConvenienceTest.createDataElement)5 DhisConvenienceTest.createProgramStageDataElement (org.hisp.dhis.DhisConvenienceTest.createProgramStageDataElement)5 DhisConvenienceTest.createTrackedEntityInstance (org.hisp.dhis.DhisConvenienceTest.createTrackedEntityInstance)5 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)5 EventTestUtils.createDataValue (org.hisp.dhis.dxf2.events.importer.EventTestUtils.createDataValue)5 EventTestUtils.createEventDataValue (org.hisp.dhis.dxf2.events.importer.EventTestUtils.createEventDataValue)5