use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class DataValidatorTest method testGetMissingDataElement.
@Test
void testGetMissingDataElement() {
final String uid = CodeGenerator.generateUid();
when(idObjectManager.get(DataElement.class, uid)).thenReturn(null);
IllegalQueryException ex = assertThrows(IllegalQueryException.class, () -> dataValidator.getAndValidateDataElement(uid));
assertEquals(ErrorCode.E1100, ex.getErrorCode());
}
use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class FilterValidatorTest method testCheckNamesAndOperatorsWhenCombinationIsInvalid.
@Test
void testCheckNamesAndOperatorsWhenCombinationIsInvalid() {
// Given
final String invalidCombination = "dimensionItemType:ilike:";
final Set<String> filters = new HashSet<>(singletonList(invalidCombination));
// When throws
final IllegalQueryException thrown = assertThrows(IllegalQueryException.class, () -> checkNamesAndOperators(filters));
// Then
assertThat(thrown.getMessage(), containsString("Unable to parse filter `dimensionItemType:ilike:`"));
}
use of org.hisp.dhis.common.IllegalQueryException 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());
}
use of org.hisp.dhis.common.IllegalQueryException 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());
}
use of org.hisp.dhis.common.IllegalQueryException 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());
}
Aggregations