Search in sources :

Example 16 with ValidationResultQuery

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)");
}
Also used : ValidationResultQuery(org.hisp.dhis.validation.comparator.ValidationResultQuery) Test(org.junit.jupiter.api.Test)

Example 17 with ValidationResultQuery

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));
}
Also used : ValidationResultQuery(org.hisp.dhis.validation.comparator.ValidationResultQuery) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 18 with ValidationResultQuery

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));
}
Also used : ValidationResultQuery(org.hisp.dhis.validation.comparator.ValidationResultQuery) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 19 with ValidationResultQuery

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));
}
Also used : ValidationResultQuery(org.hisp.dhis.validation.comparator.ValidationResultQuery) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ValidationResultQuery (org.hisp.dhis.validation.comparator.ValidationResultQuery)19 Test (org.junit.jupiter.api.Test)17 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)8 Category (org.hisp.dhis.category.Category)2 CategoryOptionGroupSet (org.hisp.dhis.category.CategoryOptionGroupSet)2 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1 IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)1 Period (org.hisp.dhis.period.Period)1 PeriodType (org.hisp.dhis.period.PeriodType)1