Search in sources :

Example 1 with JsonDataIntegritySummary

use of org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary in project dhis2-core by dhis2.

the class AbstractDataIntegrityControllerTest method getSummary.

protected final JsonDataIntegritySummary getSummary(String check) {
    JsonObject content = GET("/dataIntegrity/summary?checks={check}&timeout=1000", check).content();
    JsonDataIntegritySummary summary = content.get(check.replace('-', '_'), JsonDataIntegritySummary.class);
    assertTrue(summary.exists());
    assertTrue(summary.isObject());
    return summary;
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) JsonDataIntegritySummary(org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary)

Example 2 with JsonDataIntegritySummary

use of org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary in project dhis2-core by dhis2.

the class DataIntegrityCategoriesControllerTest method testSummaryCategories_one_default_category_option_combo.

/**
 * Ideally we would have created a second category option combo named
 * default, but we have made this impossible by unique constraint. So the
 * best we can do is changing the UID of the existing default to some other
 * UID.
 */
@Test
void testSummaryCategories_one_default_category_option_combo() {
    String uid = CodeGenerator.generateUid();
    assertEquals(uid, updateDefaultCategoryOptionComboToUid(uid));
    postSummary("categories_one_default_category_option_combo");
    JsonDataIntegritySummary summary = getSummary("categories_one_default_category_option_combo");
    assertEquals(1, summary.getCount());
    assertNull(summary.getPercentage());
}
Also used : JsonDataIntegritySummary(org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary) Test(org.junit.jupiter.api.Test)

Example 3 with JsonDataIntegritySummary

use of org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary in project dhis2-core by dhis2.

the class DataIntegrityCategoriesControllerTest method testSummaryCategories_one_default_category_option.

/**
 * Ideally we would have created a second category option named default, but
 * we have made this impossible by unique constraint. So the best we can do
 * is changing the UID of the existing default to some other UID.
 */
@Test
void testSummaryCategories_one_default_category_option() {
    String uid = CodeGenerator.generateUid();
    assertEquals(uid, updateDefaultCategoryOptionToUid(uid));
    postSummary("categories_one_default_category_option");
    JsonDataIntegritySummary summary = getSummary("categories_one_default_category_option");
    assertEquals(1, summary.getCount());
    assertNull(summary.getPercentage());
}
Also used : JsonDataIntegritySummary(org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary) Test(org.junit.jupiter.api.Test)

Example 4 with JsonDataIntegritySummary

use of org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary in project dhis2-core by dhis2.

the class DataIntegritySummaryControllerTest method testLegacyChecksHaveSummary.

@Test
void testLegacyChecksHaveSummary() {
    for (DataIntegrityCheckType type : DataIntegrityCheckType.values()) {
        String check = type.getName();
        postSummary(check);
        JsonDataIntegritySummary summary = getSummary(check);
        assertTrue(summary.getCount() >= 0, "summary threw an exception");
    }
}
Also used : DataIntegrityCheckType(org.hisp.dhis.dataintegrity.DataIntegrityCheckType) JsonDataIntegritySummary(org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary) Test(org.junit.jupiter.api.Test)

Example 5 with JsonDataIntegritySummary

use of org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary in project dhis2-core by dhis2.

the class DataIntegritySummaryControllerTest method testSingleCheckByPath.

@Test
void testSingleCheckByPath() {
    assertStatus(HttpStatus.CREATED, POST("/categories", "{'name': 'CatDog', 'shortName': 'CD', 'dataDimensionType': 'ATTRIBUTE'}"));
    postSummary("categories-no-options");
    JsonDataIntegritySummary summary = GET("/dataIntegrity/categories-no-options/summary").content().as(JsonDataIntegritySummary.class);
    assertTrue(summary.exists());
    assertTrue(summary.isObject());
    assertEquals(1, summary.getCount());
    assertEquals(50, summary.getPercentage().intValue());
}
Also used : JsonDataIntegritySummary(org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary) Test(org.junit.jupiter.api.Test)

Aggregations

JsonDataIntegritySummary (org.hisp.dhis.webapi.json.domain.JsonDataIntegritySummary)8 Test (org.junit.jupiter.api.Test)7 DataIntegrityCheckType (org.hisp.dhis.dataintegrity.DataIntegrityCheckType)1 JsonObject (org.hisp.dhis.jsontree.JsonObject)1