use of org.hisp.dhis.tracker.domain.Attribute in project dhis2-core by dhis2.
the class FileResourceSupplierTest method getEnrollment.
private Enrollment getEnrollment() {
Attribute attribute = new Attribute();
attribute.setAttribute(FILE_RESOURCE_ATTRIBUTE_UID);
attribute.setValueType(ValueType.FILE_RESOURCE);
attribute.setValue(ANOTHER_FILE_RESOURCE_UID);
Enrollment enrollment = new Enrollment();
enrollment.setAttributes(Lists.newArrayList(attribute));
return enrollment;
}
use of org.hisp.dhis.tracker.domain.Attribute in project dhis2-core by dhis2.
the class EnrollmentAttributeValidationHookTest method shouldPassValidationWhenValueIsNullAndAttributeIsNotMandatory.
@Test
void shouldPassValidationWhenValueIsNullAndAttributeIsNotMandatory() {
// given 1 attribute has null value
Attribute attribute = Attribute.builder().attribute(trackedAttribute).valueType(ValueType.TEXT).value("value").build();
Attribute attribute1 = Attribute.builder().attribute(trackedAttribute1).valueType(ValueType.TEXT).build();
// when only 1 tracked attributes is mandatory
when(program.getProgramAttributes()).thenReturn(Arrays.asList(new ProgramTrackedEntityAttribute(program, trackedEntityAttribute, false, true), new ProgramTrackedEntityAttribute(program, trackedEntityAttribute1, false, false)));
when(enrollment.getAttributes()).thenReturn(Arrays.asList(attribute, attribute1));
when(trackedEntityInstance.getTrackedEntityAttributeValues()).thenReturn(new HashSet<>(Arrays.asList(new TrackedEntityAttributeValue(trackedEntityAttribute, trackedEntityInstance), new TrackedEntityAttributeValue(trackedEntityAttribute1, trackedEntityInstance))));
when(preheat.getTrackedEntity(TrackerIdScheme.UID, enrollment.getTrackedEntity())).thenReturn(trackedEntityInstance);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
hookToTest.validateEnrollment(reporter, enrollment);
assertThat(reporter.getReportList(), hasSize(0));
}
use of org.hisp.dhis.tracker.domain.Attribute in project dhis2-core by dhis2.
the class AssignValueImplementerTest method getAttributesSameValue.
private List<Attribute> getAttributesSameValue() {
Attribute attribute = new Attribute();
attribute.setAttribute(ATTRIBUTE_ID);
attribute.setValue(TEI_ATTRIBUTE_NEW_VALUE);
return Lists.newArrayList(attribute);
}
use of org.hisp.dhis.tracker.domain.Attribute in project dhis2-core by dhis2.
the class SetMandatoryFieldValidatorTest method getAttributes.
private List<Attribute> getAttributes() {
Attribute attribute = new Attribute();
attribute.setAttribute(ATTRIBUTE_ID);
attribute.setValue(ATTRIBUTE_VALUE);
return Lists.newArrayList(attribute);
}
use of org.hisp.dhis.tracker.domain.Attribute in project dhis2-core by dhis2.
the class AttributeValueConverterService method to.
@Override
public Attribute to(TrackedEntityAttributeValue teav) {
Attribute attribute = new Attribute();
attribute.setAttribute(teav.getAttribute().getUid());
attribute.setCode(teav.getAttribute().getCode());
attribute.setDisplayName(teav.getAttribute().getDisplayName());
attribute.setCreatedAt(instantFromDate(teav.getCreated()));
attribute.setUpdatedAt(instantFromDate(teav.getLastUpdated()));
attribute.setStoredBy(teav.getStoredBy());
attribute.setValueType(teav.getAttribute().getValueType());
attribute.setValue(teav.getValue());
return attribute;
}
Aggregations