use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class EventWithoutRegistrationPreProcessorTest method testEnrollmentIsAddedIntoEventWhenItBelongsToProgramWithoutRegistration.
@Test
void testEnrollmentIsAddedIntoEventWhenItBelongsToProgramWithoutRegistration() {
// Given
Event event = new Event();
event.setProgramStage("programStageUid");
TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).build();
ProgramInstance programInstance = new ProgramInstance();
programInstance.setUid("programInstanceUid");
Program program = new Program();
program.setUid("programUid");
ProgramStage programStage = new ProgramStage();
programStage.setUid("programStageUid");
programStage.setProgram(program);
TrackerPreheat preheat = new TrackerPreheat();
preheat.putProgramInstancesWithoutRegistration("programUid", programInstance);
preheat.put(TrackerIdentifier.UID, programStage);
bundle.setPreheat(preheat);
// When
preProcessorToTest.process(bundle);
// Then
assertEquals("programInstanceUid", bundle.getEvents().get(0).getEnrollment());
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class EventWithoutRegistrationPreProcessorTest method testEnrollmentIsNotAddedIntoEventWhenItProgramStageHasNoReferenceToProgram.
@Test
void testEnrollmentIsNotAddedIntoEventWhenItProgramStageHasNoReferenceToProgram() {
// Given
Event event = new Event();
event.setProgramStage("programStageUid");
TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).build();
ProgramInstance programInstance = new ProgramInstance();
programInstance.setUid("programInstanceUid");
Program program = new Program();
program.setUid("programUid");
ProgramStage programStage = new ProgramStage();
programStage.setUid("programStageUid");
TrackerPreheat preheat = new TrackerPreheat();
preheat.putProgramInstancesWithoutRegistration("programUid", programInstance);
preheat.put(TrackerIdentifier.UID, programStage);
bundle.setPreheat(preheat);
// When
preProcessorToTest.process(bundle);
// Then
assertNull(bundle.getEvents().get(0).getEnrollment(), "programInstanceUid");
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class DhisConvenienceTest method createProgramStage.
public static ProgramStage createProgramStage(char uniqueCharacter, int minDays, boolean repeatable) {
ProgramStage programStage = new ProgramStage();
programStage.setAutoFields();
programStage.setUid(BASE_PG_UID + uniqueCharacter);
programStage.setName("ProgramStage" + uniqueCharacter);
programStage.setDescription("description" + uniqueCharacter);
programStage.setMinDaysFromStart(minDays);
programStage.setRepeatable(repeatable);
return programStage;
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class DhisConvenienceTest method createProgramStage.
public static ProgramStage createProgramStage(char uniqueCharacter, Program program) {
ProgramStage stage = createProgramStage(uniqueCharacter, 0, false);
stage.setProgram(program);
return stage;
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class ProgramRuleEngineServiceTest method setUpInstances.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private void setUpInstances() {
OrganisationUnit organisationUnitA = createOrganisationUnit('A');
Program programA = createProgram('A', new HashSet<>(), organisationUnitA);
ProgramStage programStageA = createProgramStage('A', programA);
programRuleA = createProgramRule('R', programA);
programRuleActionA = createProgramRuleAction('T');
programRuleA.setProgram(programA);
programInstance = new ProgramInstance();
programInstance.setProgram(programA);
programStageA = createProgramStage('S', programA);
programA.getProgramStages().add(programStageA);
programStageInstance = new ProgramStageInstance();
programStageInstance.setProgramStage(programStageA);
programStageInstance.setProgramInstance(programInstance);
programStageInstance.setUid("PSI1");
programRules.add(programRuleA);
}
Aggregations