Search in sources :

Example 1 with RuleValidationResult

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

the class ProgramRuleEngineDescriptionTest method testProgramRuleWithTextTrackedEntityAttribute.

@Test
void testProgramRuleWithTextTrackedEntityAttribute() {
    RuleValidationResult result = validateRuleCondition(programRuleTextAtt.getCondition(), program);
    assertNotNull(result);
    assertEquals("AttributeA == 'text_att' || Current date", 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 2 with RuleValidationResult

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

the class ProgramRuleEngineDescriptionTest method testProgramRuleWithNumericTrackedEntityAttributeWithOr.

@Test
void testProgramRuleWithNumericTrackedEntityAttributeWithOr() {
    RuleValidationResult result = validateRuleCondition(conditionNumericAttWithOR, program);
    assertNotNull(result);
    assertEquals("AttributeB == 12 or Current date", 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 3 with RuleValidationResult

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

the class ProgramRuleEngineDescriptionTest method testIncorrectRuleWithDataElement.

@Test
void testIncorrectRuleWithDataElement() {
    RuleValidationResult result = validateRuleCondition(incorrectConditionTextDE, program);
    assertNotNull(result);
    assertFalse(result.isValid());
    assertThat(result.getException(), instanceOf(IllegalStateException.class));
}
Also used : RuleValidationResult(org.hisp.dhis.rules.models.RuleValidationResult) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 4 with RuleValidationResult

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

the class ProgramRuleEngineDescriptionTest method testProgramRuleWithD2HasValueTrackedEntityAttribute.

@Test
void testProgramRuleWithD2HasValueTrackedEntityAttribute() {
    RuleValidationResult result = validateRuleCondition(programRuleWithD2HasValue.getCondition(), program);
    assertNotNull(result);
    assertEquals("AttributeA", 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 5 with RuleValidationResult

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

the class ProgramRuleEngineDescriptionTest method testProgramRuleWithNumericTrackedEntityAttributeWithAnd.

@Test
void testProgramRuleWithNumericTrackedEntityAttributeWithAnd() {
    RuleValidationResult result = validateRuleCondition(conditionNumericAttWithAND, program);
    assertNotNull(result);
    assertEquals("AttributeB == 12 and Current date", 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)

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