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;
}
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);
}
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());
}
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());
}
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());
}
Aggregations