Search in sources :

Example 16 with DataIntegrityIssue

use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.

the class DataIntegrityServiceTest method testGetProgramRulesVariableWithNoDataElement.

@Test
void testGetProgramRulesVariableWithNoDataElement() {
    programRuleVariableA.setProgram(programA);
    when(programRuleVariableService.getVariablesWithNoDataElement()).thenReturn(List.of(programRuleVariableA));
    List<DataIntegrityIssue> issues = subject.getProgramRuleVariablesWithNoDataElement();
    verify(programRuleVariableService).getVariablesWithNoDataElement();
    verify(programRuleVariableService, times(1)).getVariablesWithNoDataElement();
    assertEquals(1, issues.size());
    DataIntegrityIssue issue = issues.get(0);
    assertEquals(issueName(programA), issue.getName());
    assertContainsOnly(issue.getRefs(), issueName(programRuleVariableA));
}
Also used : DataIntegrityIssue(org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue) Test(org.junit.jupiter.api.Test)

Example 17 with DataIntegrityIssue

use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.

the class DataIntegrityServiceTest method testGetProgramRulesWithNoExpression.

@Test
void testGetProgramRulesWithNoExpression() {
    programRuleB.setCondition(null);
    when(programRuleService.getProgramRulesWithNoCondition()).thenReturn(List.of(programRuleB));
    List<DataIntegrityIssue> issues = subject.getProgramRulesWithNoCondition();
    verify(programRuleService).getProgramRulesWithNoCondition();
    verify(programRuleService, times(1)).getProgramRulesWithNoCondition();
    assertEquals(1, issues.size());
    DataIntegrityIssue issue = issues.get(0);
    assertEquals(issueName(programB), issue.getName());
    assertContainsOnly(issue.getRefs(), issueName(programRuleB));
}
Also used : DataIntegrityIssue(org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue) Test(org.junit.jupiter.api.Test)

Example 18 with DataIntegrityIssue

use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.

the class DataIntegrityServiceTest method testValidProgramIndicatorFilter.

@Test
void testValidProgramIndicatorFilter() {
    ProgramIndicator programIndicator = new ProgramIndicator();
    programIndicator.setName("Test-PI");
    programIndicator.setFilter("1 < 2");
    when(programIndicatorService.filterIsValid(anyString())).thenReturn(true);
    when(programIndicatorService.getAllProgramIndicators()).thenReturn(List.of(programIndicator));
    List<DataIntegrityIssue> issues = subject.getInvalidProgramIndicatorFilters();
    verify(expressionService, times(0)).getExpressionDescription(anyString(), any());
    assertTrue(issues.isEmpty());
}
Also used : DataIntegrityIssue(org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) Test(org.junit.jupiter.api.Test)

Aggregations

DataIntegrityIssue (org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue)18 ArrayList (java.util.ArrayList)11 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)9 Test (org.junit.jupiter.api.Test)8 DataElement (org.hisp.dhis.dataelement.DataElement)7 HashSet (java.util.HashSet)5 LinkedHashSet (java.util.LinkedHashSet)5 ParserException (org.hisp.dhis.antlr.ParserException)5 ExpressionValidationOutcome (org.hisp.dhis.expression.ExpressionValidationOutcome)5 I18n (org.hisp.dhis.i18n.I18n)5 Indicator (org.hisp.dhis.indicator.Indicator)5 Date (java.util.Date)4 DataElementGroupSet (org.hisp.dhis.dataelement.DataElementGroupSet)4 IndicatorGroupSet (org.hisp.dhis.indicator.IndicatorGroupSet)4 ValidationRule (org.hisp.dhis.validation.ValidationRule)4 System.currentTimeMillis (java.lang.System.currentTimeMillis)3 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 Collections.unmodifiableCollection (java.util.Collections.unmodifiableCollection)3 Collections.unmodifiableSet (java.util.Collections.unmodifiableSet)3