use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class EventStatusPreProcessorTest method testVisitedStatusIsConvertedToActive.
@Test
void testVisitedStatusIsConvertedToActive() {
// Given
Event event = new Event();
event.setStatus(EventStatus.VISITED);
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(EventStatus.ACTIVE, bundle.getEvents().get(0).getStatus());
}
use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class ProgramInstanceSupplierTest method verifySupplier.
@Test
void verifySupplier() {
// given
TrackerPreheat preheat = new TrackerPreheat();
preheat.put(TrackerIdentifier.UID, Lists.newArrayList(programWithRegistration, programWithoutRegistration));
// when
this.supplier.preheatAdd(params, preheat);
// then
assertNotNull(preheat.getProgramInstancesWithoutRegistration(programWithoutRegistration.getUid()));
}
use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class ProgramInstanceSupplierTest method verifySupplierWhenNoEventProgramArePresent.
@Test
void verifySupplierWhenNoEventProgramArePresent() {
// given
TrackerPreheat preheat = new TrackerPreheat();
preheat.put(TrackerIdentifier.UID, programWithRegistration);
// when
this.supplier.preheatAdd(params, preheat);
// then
final List<String> programUids = programInstances.stream().map(pi -> pi.getProgram().getUid()).collect(Collectors.toList());
for (String programUid : programUids) {
assertNull(preheat.getProgramInstancesWithoutRegistration(programUid));
}
}
use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class ProgramInstanceSupplierTest method verifySupplierWhenNoProgramsArePresent.
@Test
void verifySupplierWhenNoProgramsArePresent() {
// given
TrackerPreheat preheat = new TrackerPreheat();
when(programStore.getByType(WITHOUT_REGISTRATION)).thenReturn(List.of(programWithoutRegistration));
programInstances = rnd.objects(ProgramInstance.class, 1).collect(Collectors.toList());
// set the OrgUnit parent to null to avoid recursive errors when mapping
programInstances.forEach(p -> p.getOrganisationUnit().setParent(null));
programInstances.get(0).setProgram(programWithoutRegistration);
when(programInstanceStore.getByPrograms(List.of(programWithoutRegistration))).thenReturn(programInstances);
// when
this.supplier.preheatAdd(params, preheat);
// then
assertNotNull(preheat.getProgramInstancesWithoutRegistration(programWithoutRegistration.getUid()));
}
use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class ClassBasedSupplierTest method verifyClassBasedSupplierStrategy.
@Test
void verifyClassBasedSupplierStrategy() {
when(strategiesMap.getOrDefault(anyString(), anyString())).thenReturn("classbasedstrategy");
when(applicationContext.getBean(anyString(), eq(ClassBasedSupplierStrategy.class))).thenReturn(trackerEntityInstanceStrategy);
classBasedSupplier.preheatAdd(trackerImportParams, new TrackerPreheat());
verify(applicationContext).getBean("classbasedstrategy", ClassBasedSupplierStrategy.class);
}
Aggregations