use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class BidirectionalRelationshipsPreProcessorTest method testPreprocessorPopulateRelationshipBidirectionalFieldCorrectly.
@Test
void testPreprocessorPopulateRelationshipBidirectionalFieldCorrectly() {
Relationship uniDirectionalRelationship = new Relationship();
uniDirectionalRelationship.setRelationshipType(RELATIONSHIP_TYPE_UID);
uniDirectionalRelationship.setBidirectional(true);
Relationship biDirectionalRelationship = new Relationship();
biDirectionalRelationship.setRelationshipType(BIDIRECTIONAL_RELATIONSHIP_TYPE_UID);
biDirectionalRelationship.setBidirectional(false);
TrackerBundle bundle = TrackerBundle.builder().relationships(Lists.newArrayList(uniDirectionalRelationship, biDirectionalRelationship)).preheat(getPreheat()).build();
assertTrue(uniDirectionalRelationship.isBidirectional());
assertFalse(biDirectionalRelationship.isBidirectional());
preProcessorToTest.process(bundle);
assertFalse(uniDirectionalRelationship.isBidirectional());
assertTrue(biDirectionalRelationship.isBidirectional());
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventProgramPreProcessorTest method testTrackerEventIsEnhancedWithProgram.
@Test
void testTrackerEventIsEnhancedWithProgram() {
// Given
TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(trackerEventWithProgramStage())).preheat(preheat).build();
// When
preProcessorToTest.process(bundle);
// Then
verify(preheat).put(TrackerIdentifier.UID, programWithRegistration());
assertEquals(PROGRAM_WITH_REGISTRATION, bundle.getEvents().get(0).getProgram());
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventProgramPreProcessorTest method testTrackerEventWithProgramAndProgramStageIsNotProcessed.
@Test
void testTrackerEventWithProgramAndProgramStageIsNotProcessed() {
// Given
Event event = completeTrackerEvent();
TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).preheat(preheat).build();
// When
preProcessorToTest.process(bundle);
// Then
verify(preheat, never()).get(Program.class, PROGRAM_WITH_REGISTRATION);
verify(preheat, never()).get(ProgramStage.class, PROGRAM_STAGE_WITH_REGISTRATION);
assertEquals(PROGRAM_WITH_REGISTRATION, bundle.getEvents().get(0).getProgram());
assertEquals(PROGRAM_STAGE_WITH_REGISTRATION, bundle.getEvents().get(0).getProgramStage());
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventProgramPreProcessorTest method testProgramEventWithProgramAndProgramStageIsNotProcessed.
@Test
void testProgramEventWithProgramAndProgramStageIsNotProcessed() {
// Given
Event event = completeProgramEvent();
TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).preheat(preheat).build();
// When
preProcessorToTest.process(bundle);
// Then
// Then
verify(preheat, never()).get(Program.class, PROGRAM_WITHOUT_REGISTRATION);
verify(preheat, never()).get(ProgramStage.class, PROGRAM_STAGE_WITHOUT_REGISTRATION);
assertEquals(PROGRAM_WITHOUT_REGISTRATION, bundle.getEvents().get(0).getProgram());
assertEquals(PROGRAM_STAGE_WITHOUT_REGISTRATION, bundle.getEvents().get(0).getProgramStage());
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventProgramPreProcessorTest method testProgramEventIsEnhancedWithProgramStage.
@Test
void testProgramEventIsEnhancedWithProgramStage() {
// Given
Event event = programEventWithProgram();
TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).preheat(preheat).build();
// When
preProcessorToTest.process(bundle);
// Then
verify(preheat).put(TrackerIdentifier.UID, programStageWithoutRegistration());
assertEquals(PROGRAM_STAGE_WITHOUT_REGISTRATION, bundle.getEvents().get(0).getProgramStage());
}
Aggregations