Search in sources :

Example 1 with RuleVariableCalculatedValue

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

the class ProgramRuleEntityMapperServiceTest method testMappedRuleVariableValues.

@Test
void testMappedRuleVariableValues() {
    when(programRuleVariableService.getAllProgramRuleVariable()).thenReturn(programRuleVariables);
    RuleVariableAttribute ruleVariableAttribute;
    RuleVariableCalculatedValue ruleVariableCalculatedValue;
    List<RuleVariable> ruleVariables = subject.toMappedProgramRuleVariables();
    assertEquals(ruleVariables.size(), 3);
    for (RuleVariable variable : ruleVariables) {
        if (variable instanceof RuleVariableAttribute) {
            ruleVariableAttribute = (RuleVariableAttribute) variable;
            assertEquals(ruleVariableAttribute.trackedEntityAttribute(), programRuleVariableB.getAttribute().getUid());
            assertEquals(ruleVariableAttribute.name(), programRuleVariableB.getName());
        }
        if (variable instanceof RuleVariableCalculatedValue) {
            ruleVariableCalculatedValue = (RuleVariableCalculatedValue) variable;
            assertEquals(ruleVariableCalculatedValue.name(), programRuleVariableA.getName());
        }
    }
}
Also used : RuleVariableAttribute(org.hisp.dhis.rules.models.RuleVariableAttribute) RuleVariableCalculatedValue(org.hisp.dhis.rules.models.RuleVariableCalculatedValue) RuleVariable(org.hisp.dhis.rules.models.RuleVariable) ProgramRuleVariable(org.hisp.dhis.programrule.ProgramRuleVariable) Test(org.junit.jupiter.api.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Aggregations

DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)1 ProgramRuleVariable (org.hisp.dhis.programrule.ProgramRuleVariable)1 RuleVariable (org.hisp.dhis.rules.models.RuleVariable)1 RuleVariableAttribute (org.hisp.dhis.rules.models.RuleVariableAttribute)1 RuleVariableCalculatedValue (org.hisp.dhis.rules.models.RuleVariableCalculatedValue)1 Test (org.junit.jupiter.api.Test)1