use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class BidirectionalRelationshipsPreProcessorTest method getPreheat.
private TrackerPreheat getPreheat() {
RelationshipType uniDirectionalRelationshipType = createRelationshipType('A');
uniDirectionalRelationshipType.setUid(RELATIONSHIP_TYPE_UID);
uniDirectionalRelationshipType.setBidirectional(false);
RelationshipType biDirectionalRelationshipType = createRelationshipType('B');
biDirectionalRelationshipType.setUid(BIDIRECTIONAL_RELATIONSHIP_TYPE_UID);
biDirectionalRelationshipType.setBidirectional(true);
TrackerPreheat trackerPreheat = new TrackerPreheat();
trackerPreheat.put(TrackerIdentifier.UID, Lists.newArrayList(biDirectionalRelationshipType, uniDirectionalRelationshipType));
return trackerPreheat;
}
use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class EventNoteValidationHookTest method testNoteWithExistingUidWarnings.
@Test
void testNoteWithExistingUidWarnings() {
// Given
final Note note = rnd.nextObject(Note.class);
TrackerBundle trackerBundle = mock(TrackerBundle.class);
TrackerImportValidationContext ctx = mock(TrackerImportValidationContext.class);
TrackerPreheat preheat = mock(TrackerPreheat.class);
when(ctx.getBundle()).thenReturn(trackerBundle);
when(trackerBundle.getValidationMode()).thenReturn(ValidationMode.FULL);
when(trackerBundle.getPreheat()).thenReturn(preheat);
when(ctx.getNote(note.getNote())).thenReturn(Optional.of(new TrackedEntityComment()));
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
event.setNotes(Collections.singletonList(note));
// When
this.hook.validateEvent(reporter, event);
// Then
assertTrue(reporter.hasWarnings());
assertTrue(reporter.hasWarningReport(r -> TrackerErrorCode.E1119.equals(r.getWarningCode()) && TrackerType.EVENT.equals(r.getTrackerType()) && event.getUid().equals(r.getUid())));
assertThat(event.getNotes(), hasSize(0));
}
use of org.hisp.dhis.tracker.preheat.TrackerPreheat in project dhis2-core by dhis2.
the class AssignedUserValidationHookTest method setUp.
@BeforeEach
public void setUp() {
hookToTest = new AssignedUserValidationHook();
TrackerBundle bundle = TrackerBundle.builder().build();
TrackerPreheat preheat = new TrackerPreheat();
User user = new User();
user.setUid(USER_ID);
preheat.put(TrackerIdentifier.UID, user);
bundle.setPreheat(preheat);
when(validationContext.getBundle()).thenReturn(bundle);
ProgramStage programStage = new ProgramStage();
programStage.setEnableUserAssignment(true);
when(validationContext.getProgramStage(PROGRAM_STAGE)).thenReturn(programStage);
}
Aggregations