use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class EventStatusPreProcessorTest method testVisitedStatusIsConvertedToActive.
@Test
void testVisitedStatusIsConvertedToActive() {
WorkContext ctx = WorkContext.builder().importOptions(ImportOptions.getDefaultImportOptions()).build();
Event event = new Event();
event.setStatus(EventStatus.VISITED);
event.setDataValues(Sets.newHashSet(new DataValue("aaa", "one"), new DataValue("bbb", "two")));
preProcessor.process(event, ctx);
assertThat(event.getStatus(), is(EventStatus.ACTIVE));
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method createRandomDataValue.
private static DataValue createRandomDataValue() {
DataValue dv = new DataValue();
dv.setDataElement(CodeGenerator.generateUid());
dv.setPeriod("2021-01");
dv.setOrgUnit(CodeGenerator.generateUid());
dv.setCategoryOptionCombo(CodeGenerator.generateUid());
dv.setAttributeOptionCombo(CodeGenerator.generateUid());
dv.setComment("comment");
dv.setValue("true");
return dv;
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValueCategoryOptionComboExists.
@Test
void testValidateDataValueCategoryOptionComboExists() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).categoryOptionCombo(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7613, "Category option combo not found or not accessible for writing data: `<object1>`", context, dataValue.getCategoryOptionCombo());
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method testValidateDataValueAttrOptionComboExists.
@Test
void testValidateDataValueAttrOptionComboExists() {
DataValue dataValue = createRandomDataValue();
DataValueContext valueContext = createDataValueContext(dataValue).attrOptionCombo(null).build();
DataSetContext dataSetContext = createMinimalDataSetContext().build();
ImportContext context = createMinimalImportContext(valueContext).build();
assertTrue(validator.skipDataValue(dataValue, context, dataSetContext, valueContext));
assertConflict(ErrorCode.E7615, "Attribute option combo not found or not accessible for writing data: `<object1>`", context, dataValue.getAttributeOptionCombo());
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method createDataValueContext.
private DataValueContextBuilder createDataValueContext(DataValue dataValue) {
DataValueContextBuilder builder = DataValueContext.builder();
String deId = dataValue.getDataElement();
String period = dataValue.getPeriod();
String ouId = dataValue.getOrgUnit();
String coId = dataValue.getCategoryOptionCombo();
String aoId = dataValue.getAttributeOptionCombo();
if (deId != null) {
DataElement de = new DataElement();
de.setUid(deId);
de.setValueType(ValueType.BOOLEAN);
builder.dataElement(de);
}
if (period != null) {
Period p = PeriodType.getPeriodFromIsoString("2021-01");
builder.period(p);
}
if (ouId != null) {
OrganisationUnit ou = new OrganisationUnit();
ou.setUid(ouId);
builder.orgUnit(ou);
}
if (coId != null) {
builder.categoryOptionCombo(createMinimalOptionCombo(coId));
}
if (aoId != null) {
builder.attrOptionCombo(createMinimalOptionCombo(aoId));
}
return builder;
}
Aggregations