Search in sources :

Example 41 with DimensionalItemId

use of org.hisp.dhis.common.DimensionalItemId in project dhis2-core by dhis2.

the class CategoryOptionResolverTest method verifyExpressionIsResolvedProperly.

@Test
void verifyExpressionIsResolvedProperly() {
    // arrange
    dimensionalItemId = new DimensionalItemId(DimensionItemType.DATA_ELEMENT_OPERAND, uid1, CATEGORY_OPTION_PREFIX + uid2, uid3, createIndicatorExpression());
    String expression = createIndicatorExpression();
    when(expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION)).thenReturn(Sets.newHashSet(dimensionalItemId));
    // act
    String resolvedExpression = resolver.resolve(expression);
    // assert
    assertResolvedExpressionEquals(resolvedExpression, coc1.getUid(), coc2.getUid(), coc3.getUid());
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 42 with DimensionalItemId

use of org.hisp.dhis.common.DimensionalItemId in project dhis2-core by dhis2.

the class CategoryOptionGroupResolverTest method verifyExpressionIsResolvedProperly.

@Test
void verifyExpressionIsResolvedProperly() {
    // arrange
    dimensionalItemId = new DimensionalItemId(DimensionItemType.DATA_ELEMENT_OPERAND, uid1, CATEGORY_OPTION_GROUP_PREFIX + uid2, uid3, createIndicatorExpression());
    String expression = createIndicatorExpression();
    when(expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION)).thenReturn(Sets.newHashSet(dimensionalItemId));
    // act
    String resolvedExpression = resolver.resolve(expression);
    // assert
    assertResolvedExpressionEquals(resolvedExpression, coc1.getUid(), coc2.getUid(), coc3.getUid());
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 43 with DimensionalItemId

use of org.hisp.dhis.common.DimensionalItemId in project dhis2-core by dhis2.

the class CategoryOptionGroupResolverTest method verifyExpressionIsNotResolvedWhenDimensionalItemIdHasNoItem.

@Test
void verifyExpressionIsNotResolvedWhenDimensionalItemIdHasNoItem() {
    // arrange
    dimensionalItemId = new DimensionalItemId(DimensionItemType.DATA_ELEMENT_OPERAND, uid1, CATEGORY_OPTION_GROUP_PREFIX + uid2, uid3);
    String expression = createIndicatorExpression();
    when(expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION)).thenReturn(Sets.newHashSet(dimensionalItemId));
    // act
    String resolvedExpression = resolver.resolve(expression);
    // assert
    assertEquals(expression, resolvedExpression);
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 44 with DimensionalItemId

use of org.hisp.dhis.common.DimensionalItemId in project dhis2-core by dhis2.

the class CategoryOptionGroupResolverTest method verifyExpressionIsNotResolvedWhenCoPrefixNotInUid1.

@Test
void verifyExpressionIsNotResolvedWhenCoPrefixNotInUid1() {
    // arrange
    dimensionalItemId = new DimensionalItemId(DimensionItemType.DATA_ELEMENT_OPERAND, uid1, uid2, uid3, createIndicatorExpression());
    String expression = createIndicatorExpression();
    when(expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION)).thenReturn(Sets.newHashSet(dimensionalItemId));
    // act
    String resolvedExpression = resolver.resolve(expression);
    // assert
    assertEquals(expression, resolvedExpression);
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 45 with DimensionalItemId

use of org.hisp.dhis.common.DimensionalItemId in project dhis2-core by dhis2.

the class DataElementGroupResolverTest method verifyExpressionIsNotResolvedWhenDimensionalItemIdHasNoItem.

@Test
void verifyExpressionIsNotResolvedWhenDimensionalItemIdHasNoItem() {
    // arrange
    dimensionalItemId = new DimensionalItemId(DimensionItemType.DATA_ELEMENT_OPERAND, DATA_ELEMENT_GROUP_PREFIX + uid1, uid2, uid3);
    String expression = createIndicatorExpression();
    when(expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION)).thenReturn(Sets.newHashSet(dimensionalItemId));
    // act
    String resolvedExpression = resolver.resolve(expression);
    // assert
    assertEquals(expression, resolvedExpression);
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

DimensionalItemId (org.hisp.dhis.common.DimensionalItemId)46 Test (org.junit.jupiter.api.Test)32 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)21 DhisSpringTest (org.hisp.dhis.DhisSpringTest)13 Indicator (org.hisp.dhis.indicator.Indicator)12 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 HashMap (java.util.HashMap)11 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)9 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)9 IndicatorValue (org.hisp.dhis.indicator.IndicatorValue)8 IndicatorType (org.hisp.dhis.indicator.IndicatorType)6 DataElement (org.hisp.dhis.dataelement.DataElement)5 List (java.util.List)4 BaseDimensionalItemObject (org.hisp.dhis.common.BaseDimensionalItemObject)4 Period (org.hisp.dhis.period.Period)4 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 AllArgsConstructor (lombok.AllArgsConstructor)3