use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueCheckTest method verifyValidationFailOnMissingDataElement.
@Test
void verifyValidationFailOnMissingDataElement() {
event.setProgramStage("prgstg1");
DataElement de1 = addToDataElementMap(createDataElement('A'));
programStageA.setValidationStrategy(ValidationStrategy.ON_UPDATE_AND_INSERT);
programStageA.setProgramStageDataElements(Sets.newHashSet(createProgramStageDataElement(programStageA, de1, 1, true)));
addToDataValueMap(event.getUid(), createEventDataValue(de1.getUid(), "1"), createEventDataValue("iDontExist", "2"));
DataValue dv1 = createDataValue(de1.getUid(), "1");
DataValue dv2 = createDataValue("iDontExist", "2");
event.setDataValues(Sets.newHashSet(dv1, dv2));
final ImportSummary summary = rule.check(new ImmutableEvent(event), this.workContext);
assertHasError(summary, event, null);
assertHasConflict(summary, "iDontExist is not a valid data element", "dataElement");
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueCheckTest method verifyNoMandatoryCheckHasNoErrors.
@Test
void verifyNoMandatoryCheckHasNoErrors() {
programStageA.setValidationStrategy(ValidationStrategy.ON_COMPLETE);
event.setProgramStage("prgstg1");
DataElement de1 = addToDataElementMap(createDataElement('A'));
DataElement de2 = addToDataElementMap(createDataElement('B'));
DataValue dv1 = createDataValue(de1.getUid(), "1");
DataValue dv2 = createDataValue(de2.getUid(), "2");
event.setDataValues(Sets.newHashSet(dv1, dv2));
assertNoError(rule.check(new ImmutableEvent(event), this.workContext));
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueCheckTest method verifyMandatoryCheckFailsOnMandatoryDataElement.
@Test
void verifyMandatoryCheckFailsOnMandatoryDataElement() {
event.setProgramStage("prgstg1");
DataElement de1 = addToDataElementMap(createDataElement('A'));
DataElement de2 = addToDataElementMap(createDataElement('B'));
DataElement de3 = addToDataElementMap(createDataElement('C'));
programStageA.setProgramStageDataElements(Sets.newHashSet(createProgramStageDataElement(programStageA, de1, 1, true), createProgramStageDataElement(programStageA, de2, 2, true), createProgramStageDataElement(programStageA, de3, 3, true)));
addToDataValueMap(event.getUid(), createEventDataValue(de1.getUid(), "1"), createEventDataValue(de2.getUid(), "2"));
DataValue dv1 = createDataValue(de1.getUid(), "1");
DataValue dv2 = createDataValue(de2.getUid(), "2");
event.setDataValues(Sets.newHashSet(dv1, dv2));
final ImportSummary summary = rule.check(new ImmutableEvent(event), this.workContext);
assertHasError(summary, event, null);
assertHasConflict(summary, "value_required_but_not_provided", de3.getUid());
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueCheckTest method verifyMandatoryCheckSucceeds.
@Test
void verifyMandatoryCheckSucceeds() {
event.setProgramStage("prgstg1");
DataElement de1 = addToDataElementMap(createDataElement('A'));
DataElement de2 = addToDataElementMap(createDataElement('B'));
programStageA.setValidationStrategy(ValidationStrategy.ON_UPDATE_AND_INSERT);
programStageA.setProgramStageDataElements(Sets.newHashSet(createProgramStageDataElement(programStageA, de1, 1, true), createProgramStageDataElement(programStageA, de2, 2, true)));
addToDataValueMap(event.getUid(), createEventDataValue(de1.getUid(), "1"), createEventDataValue(de2.getUid(), "2"));
DataValue dv1 = createDataValue(de1.getUid(), "1");
DataValue dv2 = createDataValue(de2.getUid(), "2");
event.setDataValues(Sets.newHashSet(dv1, dv2));
final ImportSummary summary = rule.check(new ImmutableEvent(event), this.workContext);
assertNoError(summary);
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class ProgramStageValidationStrategyTest method createDefaultEvent.
private Event createDefaultEvent(String uid, DataValue... dataValues) {
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
event.getDataValues().addAll(Arrays.asList(dataValues));
event.setUid(uid);
event.setEvent(uid);
return event;
}
Aggregations