use of org.hisp.dhis.validation.comparator.ValidationResultQuery in project dhis2-core by dhis2.
the class ValidationResultStoreHqlTest method queryWithUser.
@Test
void queryWithUser() {
setUpUser("uid", null, null);
store.query(new ValidationResultQuery());
assertHQLMatches("from ValidationResult vr where (locate('uid',vr.organisationUnit.path) <> 0)");
}
use of org.hisp.dhis.validation.comparator.ValidationResultQuery in project dhis2-core by dhis2.
the class ValidationResultStoreTest method testQueryWithMultipleFilters.
@Test
void testQueryWithMultipleFilters() {
save(asList(validationResultAA, validationResultAB, validationResultAC, validationResultBA, validationResultBB, validationResultBC));
// test with superuser so user adds no extra restrictions
setMockUserService(superUserService);
// filter on A gives results for A
ValidationResultQuery query = new ValidationResultQuery();
query.setPe(singletonList("2017"));
query.setVr(singletonList(validationRuleA.getUid()));
query.setOu(singletonList(sourceA.getUid()));
assertEqualSets(asList(validationResultAA, validationResultAB, validationResultAC), validationResultStore.query(query));
// filter mutual exclusive gives empty result
query.setVr(singletonList(validationRuleA.getUid()));
query.setOu(singletonList(sourceB.getUid()));
assertEqualSets(emptyList(), validationResultStore.query(query));
}
use of org.hisp.dhis.validation.comparator.ValidationResultQuery in project dhis2-core by dhis2.
the class ValidationResultStoreTest method testCountWithFilters.
/**
* The exact logic of the filters is tested in depth for the query method
* which shares the filter logic with count. This test should just make sure
* that the count method used with filters has no general issues.
*/
@Test
void testCountWithFilters() {
save(asList(validationResultAA, validationResultAB, validationResultAC, validationResultBA, validationResultBB, validationResultBC));
ValidationResultQuery query = new ValidationResultQuery();
// org unit filter
query.setOu(singletonList(sourceA.getUid()));
assertEquals(3, validationResultStore.count(query));
// period filter
query.setVr(singletonList(validationRuleA.getUid()));
assertEquals(3, validationResultStore.count(query));
// period filter
query.setPe(singletonList("2017-01"));
assertEquals(3, validationResultStore.count(query));
}
use of org.hisp.dhis.validation.comparator.ValidationResultQuery in project dhis2-core by dhis2.
the class ValidationResultStoreTest method testCount.
@Test
void testCount() throws Exception {
save(asList(validationResultAA, validationResultAB, validationResultAC, validationResultBA, validationResultBB, validationResultBC));
ValidationResultQuery query = new ValidationResultQuery();
setMockUserService(superUserService);
assertEquals(6, validationResultStore.count(query));
setMockUserService(userAService);
assertEquals(6, validationResultStore.count(query));
setMockUserService(userBService);
assertEquals(3, validationResultStore.count(query));
setMockUserService(userCService);
assertEquals(1, validationResultStore.count(query));
setMockUserService(userDService);
assertEquals(1, validationResultStore.count(query));
}
Aggregations