Search in sources :

Example 16 with RuleValidationResult

use of org.hisp.dhis.rules.models.RuleValidationResult in project dhis2-core by dhis2.

the class ProgramRuleEngineDescriptionTest method testProgramRuleWithLiterals.

@Test
void testProgramRuleWithLiterals() {
    RuleValidationResult result = validateRuleCondition(conditionLiteralString, program);
    assertNotNull(result);
    assertEquals("1 > 2", result.getDescription());
    assertTrue(result.isValid());
}
Also used : RuleValidationResult(org.hisp.dhis.rules.models.RuleValidationResult) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 17 with RuleValidationResult

use of org.hisp.dhis.rules.models.RuleValidationResult in project dhis2-core by dhis2.

the class ProgramRuleEngineDescriptionTest method testProgramRuleWithTextDataElement.

@Test
void testProgramRuleWithTextDataElement() {
    RuleValidationResult result = validateRuleCondition(programRuleTextDE.getCondition(), program);
    assertNotNull(result);
    assertEquals("DataElementD == 'text_de'", result.getDescription());
    assertTrue(result.isValid());
}
Also used : RuleValidationResult(org.hisp.dhis.rules.models.RuleValidationResult) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 18 with RuleValidationResult

use of org.hisp.dhis.rules.models.RuleValidationResult in project dhis2-core by dhis2.

the class ProgramRuleEngineServiceTest method testGetDescription.

@Test
void testGetDescription() {
    RuleValidationResult result = RuleValidationResult.builder().isValid(true).build();
    when(programRuleService.getProgramRule(anyString())).thenReturn(programRuleA);
    when(programRuleEngine.getDescription(programRuleA.getCondition(), program)).thenReturn(result);
    assertNotNull(result);
    assertTrue(result.isValid());
}
Also used : RuleValidationResult(org.hisp.dhis.rules.models.RuleValidationResult) Test(org.junit.jupiter.api.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Aggregations

RuleValidationResult (org.hisp.dhis.rules.models.RuleValidationResult)18 Test (org.junit.jupiter.api.Test)16 DhisSpringTest (org.hisp.dhis.DhisSpringTest)15 DescriptiveWebMessage (org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage)2 I18n (org.hisp.dhis.i18n.I18n)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)1