Search in sources :

Example 31 with DataValue

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

the class FileResourceSupplierTest method getEvent.

private Event getEvent() {
    DataValue fileResourceDataValue = new DataValue();
    fileResourceDataValue.setDataElement(FILE_RESOURCE_DATA_ELEMENT_UID);
    fileResourceDataValue.setValue(FILE_RESOURCE_UID);
    DataValue emptyFileResourceDataValue = new DataValue();
    emptyFileResourceDataValue.setDataElement(EMPTY_FILE_RESOURCE_DATA_ELEMENT_UID);
    emptyFileResourceDataValue.setValue("");
    DataValue nullFileResourceDataValue = new DataValue();
    nullFileResourceDataValue.setDataElement(NULL_FILE_RESOURCE_DATA_ELEMENT_UID);
    nullFileResourceDataValue.setValue(null);
    DataValue numericDataValue = new DataValue();
    numericDataValue.setDataElement(NUMERIC_DATA_ELEMENT_UID);
    numericDataValue.setValue("3");
    Event event = new Event();
    event.setDataValues(Sets.newHashSet(fileResourceDataValue, emptyFileResourceDataValue, nullFileResourceDataValue, numericDataValue));
    return event;
}
Also used : DataValue(org.hisp.dhis.tracker.domain.DataValue) Event(org.hisp.dhis.tracker.domain.Event)

Example 32 with DataValue

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

the class SetMandatoryFieldValidatorTest method getActiveEventDataValues.

private Set<DataValue> getActiveEventDataValues() {
    DataValue dataValue = new DataValue();
    dataValue.setValue(DATA_ELEMENT_VALUE);
    dataValue.setDataElement(DATA_ELEMENT_ID);
    return Sets.newHashSet(dataValue);
}
Also used : DataValue(org.hisp.dhis.tracker.domain.DataValue)

Example 33 with DataValue

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

the class EventDataValuesValidationHookTest method succeedsOnScheduledEventWithDataElementValueIsNullAndEventStatusSkippedOrScheduled.

@Test
void succeedsOnScheduledEventWithDataElementValueIsNullAndEventStatusSkippedOrScheduled() {
    setUpIdentifiers();
    DataElement validDataElement = dataElement();
    when(context.getDataElement(dataElementUid)).thenReturn(validDataElement);
    ProgramStage programStage = programStage(validDataElement, true);
    when(context.getProgramStage(programStageUid)).thenReturn(programStage);
    ValidationErrorReporter reporter = new ValidationErrorReporter(context);
    DataValue validDataValue = dataValue();
    validDataValue.setValue(null);
    Event event = Event.builder().programStage(programStage.getUid()).status(EventStatus.SCHEDULE).dataValues(Set.of(validDataValue)).build();
    hook.validateEvent(reporter, event);
    assertFalse(reporter.hasErrors());
}
Also used : ProgramStageDataElement(org.hisp.dhis.program.ProgramStageDataElement) DataElement(org.hisp.dhis.dataelement.DataElement) DataValue(org.hisp.dhis.tracker.domain.DataValue) Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 34 with DataValue

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

the class EventDataValuesValidationHookTest method succeedsWhenDataElementIsPartOfProgramStageAndIdSchemeIsSetToCode.

@Test
void succeedsWhenDataElementIsPartOfProgramStageAndIdSchemeIsSetToCode() {
    TrackerIdentifierParams params = TrackerIdentifierParams.builder().idScheme(TrackerIdentifier.CODE).programIdScheme(TrackerIdentifier.UID).programStageIdScheme(TrackerIdentifier.UID).dataElementIdScheme(TrackerIdentifier.CODE).build();
    when(context.getIdentifiers()).thenReturn(params);
    DataElement dataElement = dataElement();
    dataElement.setCode("DE_424050");
    when(context.getDataElement(dataElement.getCode())).thenReturn(dataElement);
    ProgramStage programStage = programStage(dataElement);
    when(context.getProgramStage(programStageUid)).thenReturn(programStage);
    ValidationErrorReporter reporter = new ValidationErrorReporter(context);
    DataValue dataValue = dataValue();
    dataValue.setDataElement("DE_424050");
    Event event = Event.builder().programStage(programStage.getUid()).status(EventStatus.ACTIVE).dataValues(Set.of(dataValue)).build();
    hook.validateEvent(reporter, event);
    assertFalse(reporter.hasErrors());
}
Also used : ProgramStageDataElement(org.hisp.dhis.program.ProgramStageDataElement) DataElement(org.hisp.dhis.dataelement.DataElement) DataValue(org.hisp.dhis.tracker.domain.DataValue) TrackerIdentifierParams(org.hisp.dhis.tracker.TrackerIdentifierParams) Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 35 with DataValue

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

the class EventDataValuesValidationHookTest method succeedsWhenMandatoryDataElementIsPartOfProgramStageAndIdSchemeIsSetToCode.

@Test
void succeedsWhenMandatoryDataElementIsPartOfProgramStageAndIdSchemeIsSetToCode() {
    TrackerIdentifierParams params = TrackerIdentifierParams.builder().idScheme(TrackerIdentifier.CODE).programIdScheme(TrackerIdentifier.UID).programStageIdScheme(TrackerIdentifier.UID).dataElementIdScheme(TrackerIdentifier.CODE).build();
    when(context.getIdentifiers()).thenReturn(params);
    DataElement dataElement = dataElement();
    dataElement.setCode("DE_424050");
    when(context.getDataElement(dataElement.getCode())).thenReturn(dataElement);
    ProgramStage programStage = programStage(dataElement, true);
    when(context.getProgramStage(programStageUid)).thenReturn(programStage);
    ValidationErrorReporter reporter = new ValidationErrorReporter(context);
    DataValue dataValue = dataValue();
    dataValue.setDataElement("DE_424050");
    Event event = Event.builder().programStage(programStage.getUid()).status(EventStatus.COMPLETED).dataValues(Set.of(dataValue)).build();
    hook.validateEvent(reporter, event);
    assertFalse(reporter.hasErrors());
}
Also used : ProgramStageDataElement(org.hisp.dhis.program.ProgramStageDataElement) DataElement(org.hisp.dhis.dataelement.DataElement) DataValue(org.hisp.dhis.tracker.domain.DataValue) TrackerIdentifierParams(org.hisp.dhis.tracker.TrackerIdentifierParams) Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Aggregations

DataValue (org.hisp.dhis.tracker.domain.DataValue)45 Event (org.hisp.dhis.tracker.domain.Event)35 DataElement (org.hisp.dhis.dataelement.DataElement)33 Test (org.junit.jupiter.api.Test)29 ProgramStage (org.hisp.dhis.program.ProgramStage)26 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)25 ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)19 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)10 EventDataValue (org.hisp.dhis.eventdatavalue.EventDataValue)9 Lists (com.google.common.collect.Lists)6 Sets (com.google.common.collect.Sets)6 List (java.util.List)6 Map (java.util.Map)6 Optional (java.util.Optional)6 Set (java.util.Set)6 ValueType (org.hisp.dhis.common.ValueType)6 EventStatus (org.hisp.dhis.event.EventStatus)6 RuleActionAssign (org.hisp.dhis.rules.models.RuleActionAssign)6 SettingKey (org.hisp.dhis.setting.SettingKey)6 SystemSettingManager (org.hisp.dhis.setting.SystemSettingManager)6