Search in sources :

Example 1 with TrackedEntityInstanceCriteria

use of org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria in project dhis2-core by dhis2.

the class TrackedEntityCriteriaMapperTest method verifyCriteriaMappingFailOnMissingProgram.

@Test
void verifyCriteriaMappingFailOnMissingProgram() {
    TrackedEntityInstanceCriteria criteria = new TrackedEntityInstanceCriteria();
    criteria.setProgram(programA.getUid() + 'A');
    IllegalQueryException e = assertThrows(IllegalQueryException.class, () -> trackedEntityCriteriaMapper.map(criteria));
    assertEquals("Program does not exist: " + programA.getUid() + "A", e.getMessage());
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) TrackedEntityInstanceCriteria(org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria) DhisWebSpringTest(org.hisp.dhis.webapi.DhisWebSpringTest) Test(org.junit.jupiter.api.Test)

Example 2 with TrackedEntityInstanceCriteria

use of org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria in project dhis2-core by dhis2.

the class TrackedEntityCriteriaMapperTest method verifyCriteriaMappingFailOnMissingAttribute.

@Test
void verifyCriteriaMappingFailOnMissingAttribute() {
    TrackedEntityInstanceCriteria criteria = new TrackedEntityInstanceCriteria();
    criteria.setAttribute(newHashSet(attrD.getUid(), attrE.getUid(), "missing"));
    IllegalQueryException e = assertThrows(IllegalQueryException.class, () -> trackedEntityCriteriaMapper.map(criteria));
    assertEquals("Attribute does not exist: missing", e.getMessage());
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) TrackedEntityInstanceCriteria(org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria) DhisWebSpringTest(org.hisp.dhis.webapi.DhisWebSpringTest) Test(org.junit.jupiter.api.Test)

Example 3 with TrackedEntityInstanceCriteria

use of org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria in project dhis2-core by dhis2.

the class TrackedEntityCriteriaMapperTest method testGetFromUrlFailOnNonProvidedAndAssignedUsers.

@Test
void testGetFromUrlFailOnNonProvidedAndAssignedUsers() {
    TrackedEntityInstanceCriteria criteria = new TrackedEntityInstanceCriteria();
    criteria.setAssignedUser(userIds);
    criteria.setAssignedUserMode(AssignedUserSelectionMode.CURRENT);
    IllegalQueryException e = assertThrows(IllegalQueryException.class, () -> trackedEntityCriteriaMapper.map(criteria));
    assertEquals("Assigned User uid(s) cannot be specified if selectionMode is not PROVIDED", e.getMessage());
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) TrackedEntityInstanceCriteria(org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria) DhisWebSpringTest(org.hisp.dhis.webapi.DhisWebSpringTest) Test(org.junit.jupiter.api.Test)

Example 4 with TrackedEntityInstanceCriteria

use of org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria in project dhis2-core by dhis2.

the class TrackedEntityCriteriaMapperTest method verifyCriteriaMappingFailOnMissingOrgUnit.

@Test
void verifyCriteriaMappingFailOnMissingOrgUnit() {
    TrackedEntityInstanceCriteria criteria = new TrackedEntityInstanceCriteria();
    criteria.setOu(organisationUnit.getUid() + "A");
    IllegalQueryException e = assertThrows(IllegalQueryException.class, () -> trackedEntityCriteriaMapper.map(criteria));
    assertEquals("Organisation unit does not exist: " + organisationUnit.getUid() + "A", e.getMessage());
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) TrackedEntityInstanceCriteria(org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria) DhisWebSpringTest(org.hisp.dhis.webapi.DhisWebSpringTest) Test(org.junit.jupiter.api.Test)

Example 5 with TrackedEntityInstanceCriteria

use of org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria in project dhis2-core by dhis2.

the class TrackedEntityCriteriaMapperTest method verifyCriteriaMappingFailOnMissingFilter.

@Test
void verifyCriteriaMappingFailOnMissingFilter() {
    TrackedEntityInstanceCriteria criteria = new TrackedEntityInstanceCriteria();
    criteria.setFilter(newHashSet(filtF.getUid(), filtG.getUid(), "missing"));
    IllegalQueryException e = assertThrows(IllegalQueryException.class, () -> trackedEntityCriteriaMapper.map(criteria));
    assertEquals("Attribute does not exist: missing", e.getMessage());
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) TrackedEntityInstanceCriteria(org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria) DhisWebSpringTest(org.hisp.dhis.webapi.DhisWebSpringTest) Test(org.junit.jupiter.api.Test)

Aggregations

IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)11 TrackedEntityInstanceCriteria (org.hisp.dhis.webapi.controller.event.webrequest.TrackedEntityInstanceCriteria)11 DhisWebSpringTest (org.hisp.dhis.webapi.DhisWebSpringTest)8 Test (org.junit.jupiter.api.Test)8 HashSet (java.util.HashSet)4 AssignedUserSelectionMode (org.hisp.dhis.common.AssignedUserSelectionMode)4 OrganisationUnitSelectionMode (org.hisp.dhis.common.OrganisationUnitSelectionMode)4 QueryOperator (org.hisp.dhis.common.QueryOperator)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 OrganisationUnitService (org.hisp.dhis.organisationunit.OrganisationUnitService)4 Program (org.hisp.dhis.program.Program)4 ProgramService (org.hisp.dhis.program.ProgramService)4 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)4 TrackedEntityAttributeService (org.hisp.dhis.trackedentity.TrackedEntityAttributeService)4 TrackedEntityInstanceQueryParams (org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams)4 TrackedEntityType (org.hisp.dhis.trackedentity.TrackedEntityType)4 TrackedEntityTypeService (org.hisp.dhis.trackedentity.TrackedEntityTypeService)4 CurrentUserService (org.hisp.dhis.user.CurrentUserService)4 User (org.hisp.dhis.user.User)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3