Search in sources :

Example 6 with TrackerBundle

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());
}
Also used : Relationship(org.hisp.dhis.tracker.domain.Relationship) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Example 7 with TrackerBundle

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());
}
Also used : TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Example 8 with TrackerBundle

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());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Example 9 with TrackerBundle

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());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Example 10 with TrackerBundle

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());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Aggregations

TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)74 Test (org.junit.jupiter.api.Test)43 Event (org.hisp.dhis.tracker.domain.Event)29 User (org.hisp.dhis.user.User)21 ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)19 List (java.util.List)17 Enrollment (org.hisp.dhis.tracker.domain.Enrollment)15 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)14 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)14 Mockito.mock (org.mockito.Mockito.mock)14 TrackerErrorCode (org.hisp.dhis.tracker.report.TrackerErrorCode)13 TrackerImportStrategy (org.hisp.dhis.tracker.TrackerImportStrategy)12 TrackedEntity (org.hisp.dhis.tracker.domain.TrackedEntity)12 TrackerImportValidationContext (org.hisp.dhis.tracker.validation.TrackerImportValidationContext)12 Collections (java.util.Collections)11 ProgramStage (org.hisp.dhis.program.ProgramStage)11 Objects (java.util.Objects)10 Program (org.hisp.dhis.program.Program)10 ValidationMode (org.hisp.dhis.tracker.ValidationMode)10 Relationship (org.hisp.dhis.tracker.domain.Relationship)10