use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class AssignValueImplementerTest method getEventWithDataValueNOTSetInDifferentProgramStage.
private Event getEventWithDataValueNOTSetInDifferentProgramStage() {
Event event = new Event();
event.setEvent(SECOND_EVENT_ID);
event.setStatus(EventStatus.ACTIVE);
event.setProgramStage(secondProgramStage.getUid());
return event;
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class AssignValueImplementerTest method testAssignDataElementValueForEventsWhenDataElementIsAlreadyPresent.
@Test
void testAssignDataElementValueForEventsWhenDataElementIsAlreadyPresent() {
List<Event> events = Lists.newArrayList(getEventWithDataValueSet());
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_OLD_VALUE, newDataValue.get().getValue());
assertEquals(1, eventIssues.size());
assertEquals(1, eventIssues.get(FIRST_EVENT_ID).size());
assertEquals(ERROR, eventIssues.get(FIRST_EVENT_ID).get(0).getIssueType());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class AssignValueImplementerTest method testAssignDataElementValueForEventsWhenDataElementIsEmpty.
@Test
void testAssignDataElementValueForEventsWhenDataElementIsEmpty() {
List<Event> events = Lists.newArrayList(getEventWithDataValueNOTSet());
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());
assertEquals(DATA_ELEMENT_NEW_VALUE, newDataValue.get().getValue());
assertEquals(1, eventIssues.size());
assertEquals(1, eventIssues.get(SECOND_EVENT_ID).size());
assertEquals(WARNING, eventIssues.get(SECOND_EVENT_ID).get(0).getIssueType());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class AssignValueImplementerTest method getEventWithDataValueSet.
private Event getEventWithDataValueSet() {
Event event = new Event();
event.setEvent(FIRST_EVENT_ID);
event.setStatus(EventStatus.ACTIVE);
event.setProgramStage(firstProgramStage.getUid());
event.setDataValues(getEventDataValues());
return event;
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class AssignValueImplementerTest method getEventWithDataValueSetSameValue.
private Event getEventWithDataValueSetSameValue() {
Event event = new Event();
event.setEvent(FIRST_EVENT_ID);
event.setStatus(EventStatus.ACTIVE);
event.setProgramStage(firstProgramStage.getUid());
event.setDataValues(getEventDataValuesSameValue());
return event;
}
Aggregations