use of org.hisp.dhis.tracker.domain.DataValue in project dhis2-core by dhis2.
the class AssignValueImplementerTest method testAssignDataElementValueForEventsWhenDataElementIsAlreadyPresentAndHasSameValue.
@Test
void testAssignDataElementValueForEventsWhenDataElementIsAlreadyPresentAndHasSameValue() {
List<Event> events = Lists.newArrayList(getEventWithDataValueSetSameValue());
bundle.setEvents(events);
bundle.setRuleEffects(getRuleEventEffects(events));
Map<String, List<ProgramRuleIssue>> eventIssues = implementerToTest.validateEvents(bundle);
Event event = bundle.getEvents().stream().filter(e -> e.getEvent().equals(FIRST_EVENT_ID)).findAny().get();
Optional<DataValue> newDataValue = event.getDataValues().stream().filter(dv -> dv.getDataElement().equals(dataElementA.getUid())).findAny();
assertTrue(newDataValue.isPresent());
assertEquals(DATA_ELEMENT_NEW_VALUE, newDataValue.get().getValue());
assertEquals(1, eventIssues.size());
assertEquals(1, eventIssues.get(FIRST_EVENT_ID).size());
assertEquals(WARNING, eventIssues.get(FIRST_EVENT_ID).get(0).getIssueType());
}
use of org.hisp.dhis.tracker.domain.DataValue in project dhis2-core by dhis2.
the class AssignValueImplementerTest method getEventDataValues.
private Set<DataValue> getEventDataValues() {
DataValue dataValue = new DataValue();
dataValue.setValue(DATA_ELEMENT_OLD_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 AssignValueImplementerTest method getEventDataValuesSameValue.
private Set<DataValue> getEventDataValuesSameValue() {
DataValue dataValue = new DataValue();
dataValue.setValue(DATA_ELEMENT_NEW_VALUE_PAYLOAD);
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 AssignValueImplementerTest method testAssignDataElementValueForEventsWhenDataElementIsAlreadyPresentAndSystemSettingToOverwriteIsTrue.
@Test
void testAssignDataElementValueForEventsWhenDataElementIsAlreadyPresentAndSystemSettingToOverwriteIsTrue() {
List<Event> events = Lists.newArrayList(getEventWithDataValueSet());
bundle.setEvents(events);
bundle.setRuleEffects(getRuleEventEffects(events));
when(systemSettingManager.getBooleanSetting(SettingKey.RULE_ENGINE_ASSIGN_OVERWRITE)).thenReturn(Boolean.TRUE);
Map<String, List<ProgramRuleIssue>> eventIssues = implementerToTest.validateEvents(bundle);
Event event = bundle.getEvents().stream().filter(e -> e.getEvent().equals(FIRST_EVENT_ID)).findAny().get();
Optional<DataValue> newDataValue = event.getDataValues().stream().filter(dv -> dv.getDataElement().equals(dataElementA.getUid())).findAny();
assertTrue(newDataValue.isPresent());
assertEquals(DATA_ELEMENT_NEW_VALUE, newDataValue.get().getValue());
assertEquals(1, eventIssues.size());
assertEquals(1, eventIssues.get(FIRST_EVENT_ID).size());
assertEquals(WARNING, eventIssues.get(FIRST_EVENT_ID).get(0).getIssueType());
}
use of org.hisp.dhis.tracker.domain.DataValue in project dhis2-core by dhis2.
the class AssignValueImplementerTest method testAssignDataElementValueForEventsWhenDataElementIsEmptyAndFromDifferentProgramStage.
@Test
void testAssignDataElementValueForEventsWhenDataElementIsEmptyAndFromDifferentProgramStage() {
List<Event> events = Lists.newArrayList(getEventWithDataValueNOTSetInDifferentProgramStage());
bundle.setEvents(events);
bundle.setRuleEffects(getRuleEventEffects(events));
Map<String, List<ProgramRuleIssue>> eventIssues = implementerToTest.validateEvents(bundle);
Event event = bundle.getEvents().stream().filter(e -> e.getEvent().equals(SECOND_EVENT_ID)).findAny().get();
Optional<DataValue> newDataValue = event.getDataValues().stream().filter(dv -> dv.getDataElement().equals(dataElementA.getUid())).findAny();
assertTrue(!newDataValue.isPresent());
assertTrue(eventIssues.isEmpty());
}
Aggregations