use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class TrackerRelationshipCriteriaTest method getIdentifierClassThrowsIfTrackedEntityAndEnrollmentAreSet.
@Test
void getIdentifierClassThrowsIfTrackedEntityAndEnrollmentAreSet() {
TrackerRelationshipCriteria criteria = new TrackerRelationshipCriteria();
criteria.setTrackedEntity("Hq3Kc6HK4OZ");
criteria.setEnrollment("Hq3Kc6HK4OZ");
WebMessageException exception = assertThrows(WebMessageException.class, criteria::getIdentifierClass);
assertEquals(BAD_REQUEST.value(), exception.getWebMessage().getHttpStatusCode());
assertEquals("Only one of parameters 'trackedEntity', 'enrollment' or 'event' is allowed.", exception.getWebMessage().getMessage());
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class TrackerRelationshipCriteriaTest method getIdentifierClassThrowsIfAllParamsAreSet.
@Test
void getIdentifierClassThrowsIfAllParamsAreSet() {
TrackerRelationshipCriteria criteria = new TrackerRelationshipCriteria();
criteria.setTrackedEntity("Hq3Kc6HK4OZ");
criteria.setTei("Hq3Kc6HK4OZ");
criteria.setEnrollment("Hq3Kc6HK4OZ");
criteria.setEvent("Hq3Kc6HK4OZ");
WebMessageException exception = assertThrows(WebMessageException.class, criteria::getIdentifierClass);
assertEquals(BAD_REQUEST.value(), exception.getWebMessage().getHttpStatusCode());
assertEquals("Only one of parameters 'trackedEntity', 'enrollment' or 'event' is allowed.", exception.getWebMessage().getMessage());
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class TrackerRelationshipCriteriaTest method getIdentifierClassThrowsIfTeiAndEnrollmentAreSet.
@Test
void getIdentifierClassThrowsIfTeiAndEnrollmentAreSet() {
TrackerRelationshipCriteria criteria = new TrackerRelationshipCriteria();
criteria.setTei("Hq3Kc6HK4OZ");
criteria.setEnrollment("Hq3Kc6HK4OZ");
WebMessageException exception = assertThrows(WebMessageException.class, criteria::getIdentifierClass);
assertEquals(BAD_REQUEST.value(), exception.getWebMessage().getHttpStatusCode());
assertEquals("Only one of parameters 'trackedEntity', 'enrollment' or 'event' is allowed.", exception.getWebMessage().getMessage());
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class TrackerRelationshipCriteriaTest method getIdentifierParamThrowsIfNoParamsIsSet.
@Test
void getIdentifierParamThrowsIfNoParamsIsSet() {
TrackerRelationshipCriteria criteria = new TrackerRelationshipCriteria();
WebMessageException exception = assertThrows(WebMessageException.class, criteria::getIdentifierParam);
assertEquals(BAD_REQUEST.value(), exception.getWebMessage().getHttpStatusCode());
assertEquals("Missing required parameter 'trackedEntity', 'enrollment' or 'event'.", exception.getWebMessage().getMessage());
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class TrackedEntityInstanceServiceTest method testUpdateTeiAfterChangingTextPatternForGeneratedAttribute.
@Test
void testUpdateTeiAfterChangingTextPatternForGeneratedAttribute() {
TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance(maleA.getUid());
assertNotNull(trackedEntityInstance.getEnrollments());
assertEquals(1, trackedEntityInstance.getEnrollments().size());
Enrollment enrollment1 = trackedEntityInstance.getEnrollments().get(0);
enrollment1.setStatus(EnrollmentStatus.COMPLETED);
enrollment1.setCompletedBy("test");
enrollment1.setCompletedDate(new Date());
Enrollment enrollment2 = new Enrollment();
enrollment2.setTrackedEntityInstance(maleA.getUid());
TextPattern textPattern = new TextPattern(Lists.newArrayList(new TextPatternSegment(TextPatternMethod.RANDOM, "RANDOM(#######)")));
textPattern.setOwnerUid("owneruid");
textPattern.setOwnerObject(Objects.CONSTANT);
uniqueIdAttribute.setTextPattern(textPattern);
trackedEntityAttributeService.updateTrackedEntityAttribute(uniqueIdAttribute);
enrollment2.setEnrollmentDate(new Date());
enrollment2.setOrgUnit(organisationUnitA.getUid());
enrollment2.setProgram(programA.getUid());
enrollment2.setStatus(EnrollmentStatus.ACTIVE);
trackedEntityInstance.getEnrollments().add(enrollment2);
ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstance(trackedEntityInstance, null, null, true);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(ImportStatus.SUCCESS, importSummary.getEnrollments().getStatus());
}
Aggregations