Search in sources :

Example 6 with Enrollment

use of org.hisp.dhis.tracker.domain.Enrollment in project dhis2-core by dhis2.

the class AssignValueImplementerTest method getEnrollmentWithAttributeSet.

private Enrollment getEnrollmentWithAttributeSet() {
    Enrollment enrollment = new Enrollment();
    enrollment.setEnrollment(FIRST_ENROLLMENT_ID);
    enrollment.setStatus(EnrollmentStatus.ACTIVE);
    enrollment.setAttributes(getAttributes());
    return enrollment;
}
Also used : Enrollment(org.hisp.dhis.tracker.domain.Enrollment)

Example 7 with Enrollment

use of org.hisp.dhis.tracker.domain.Enrollment in project dhis2-core by dhis2.

the class StrategyPreProcessorTest method setUp.

@BeforeEach
void setUp() {
    tei = new TrackedEntityInstance();
    tei.setUid(TEI_UID);
    trackedEntity = new TrackedEntity();
    trackedEntity.setTrackedEntity(TEI_UID);
    newTrackedEntity = new TrackedEntity();
    newTrackedEntity.setTrackedEntity(NEW_TEI_UID);
    pi = new ProgramInstance();
    pi.setUid(ENROLLMENT_UID);
    enrollment = new Enrollment();
    enrollment.setEnrollment(ENROLLMENT_UID);
    newEnrollment = new Enrollment();
    newEnrollment.setEnrollment(NEW_ENROLLMENT_UID);
    psi = new ProgramStageInstance();
    psi.setUid(EVENT_UID);
    event = new Event();
    event.setEvent(EVENT_UID);
    newEvent = new Event();
    newEvent.setEvent(NEW_EVENT_UID);
    relationship = new Relationship();
    relationship.setUid(RELATIONSHIP_UID);
    payloadRelationship = new org.hisp.dhis.tracker.domain.Relationship();
    payloadRelationship.setRelationship(RELATIONSHIP_UID);
    newPayloadRelationship = new org.hisp.dhis.tracker.domain.Relationship();
    newPayloadRelationship.setRelationship(NEW_RELATIONSHIP_UID);
    Mockito.when(preheat.getTrackedEntity(TrackerIdScheme.UID, TEI_UID)).thenReturn(tei);
    Mockito.when(preheat.getEnrollment(TrackerIdScheme.UID, ENROLLMENT_UID)).thenReturn(pi);
    Mockito.when(preheat.getEvent(TrackerIdScheme.UID, EVENT_UID)).thenReturn(psi);
    Mockito.when(preheat.getRelationship(TrackerIdScheme.UID, payloadRelationship)).thenReturn(relationship);
}
Also used : TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) ProgramInstance(org.hisp.dhis.program.ProgramInstance) Relationship(org.hisp.dhis.relationship.Relationship) Enrollment(org.hisp.dhis.tracker.domain.Enrollment) Event(org.hisp.dhis.tracker.domain.Event) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with Enrollment

use of org.hisp.dhis.tracker.domain.Enrollment 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;
}
Also used : Attribute(org.hisp.dhis.tracker.domain.Attribute) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) Enrollment(org.hisp.dhis.tracker.domain.Enrollment)

Example 9 with Enrollment

use of org.hisp.dhis.tracker.domain.Enrollment in project dhis2-core by dhis2.

the class ShowErrorWarningImplementerTest method getEnrollments.

private List<Enrollment> getEnrollments() {
    Enrollment activeEnrollment = new Enrollment();
    activeEnrollment.setEnrollment(ACTIVE_ENROLLMENT_ID);
    activeEnrollment.setStatus(EnrollmentStatus.ACTIVE);
    Enrollment completedEnrollment = new Enrollment();
    completedEnrollment.setEnrollment(COMPLETED_ENROLLMENT_ID);
    completedEnrollment.setStatus(EnrollmentStatus.COMPLETED);
    return Lists.newArrayList(activeEnrollment, completedEnrollment);
}
Also used : Enrollment(org.hisp.dhis.tracker.domain.Enrollment)

Example 10 with Enrollment

use of org.hisp.dhis.tracker.domain.Enrollment in project dhis2-core by dhis2.

the class TrackerSideEffectDataBundleTest method testSideEffectDataBundleForEnrollment.

@Test
void testSideEffectDataBundleForEnrollment() {
    Enrollment enrollment = new Enrollment();
    enrollment.setEnrollment("test-enrollment");
    Map<String, List<TrackerRuleEngineSideEffect>> enrollmentRuleEffects = new HashMap<>();
    enrollmentRuleEffects.put(enrollment.getEnrollment(), Lists.newArrayList());
    ProgramInstance programInstance = new ProgramInstance();
    programInstance.setAutoFields();
    TrackerSideEffectDataBundle bundle = TrackerSideEffectDataBundle.builder().enrollmentRuleEffects(enrollmentRuleEffects).accessedBy("testUser").importStrategy(TrackerImportStrategy.CREATE).object(programInstance.getUid()).klass(ProgramInstance.class).build();
    assertEquals(programInstance.getUid(), bundle.getObject());
    assertEquals(ProgramInstance.class, bundle.getKlass());
    assertTrue(bundle.getEnrollmentRuleEffects().containsKey("test-enrollment"));
    assertTrue(bundle.getEventRuleEffects().isEmpty());
    assertEquals(TrackerImportStrategy.CREATE, bundle.getImportStrategy());
    assertEquals(MessageType.TRACKER_SIDE_EFFECT, bundle.getMessageType());
}
Also used : HashMap(java.util.HashMap) ProgramInstance(org.hisp.dhis.program.ProgramInstance) Enrollment(org.hisp.dhis.tracker.domain.Enrollment) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

Enrollment (org.hisp.dhis.tracker.domain.Enrollment)88 Test (org.junit.jupiter.api.Test)67 ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)53 Event (org.hisp.dhis.tracker.domain.Event)25 TrackedEntity (org.hisp.dhis.tracker.domain.TrackedEntity)25 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)24 Program (org.hisp.dhis.program.Program)21 TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)19 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)17 List (java.util.List)16 Optional (java.util.Optional)15 ProgramInstance (org.hisp.dhis.program.ProgramInstance)15 TrackerPreheat (org.hisp.dhis.tracker.preheat.TrackerPreheat)15 Sets (com.google.common.collect.Sets)14 Collectors (java.util.stream.Collectors)14 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)14 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)14 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)14 BeforeEach (org.junit.jupiter.api.BeforeEach)14 Mockito.when (org.mockito.Mockito.when)14