Search in sources :

Example 11 with BaseDimensionalItemObject

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

the class EnrollmentAnalyticsManagerTest method verifyGetColumnOfTypeCoordinateAndNoProgramStages.

@Test
void verifyGetColumnOfTypeCoordinateAndNoProgramStages() {
    // Given
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    QueryItem item = new QueryItem(dio);
    item.setValueType(ValueType.COORDINATE);
    // When
    String columnSql = subject.getColumn(item);
    // Then
    assertThat(columnSql, is("ax.\"" + dataElementA.getUid() + "\""));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 12 with BaseDimensionalItemObject

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

the class EnrollmentAnalyticsManagerTest method verifyGetColumnOfTypeCoordinateAndWithProgramStages.

@Test
void verifyGetColumnOfTypeCoordinateAndWithProgramStages() {
    // Given
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    QueryItem item = new QueryItem(dio);
    item.setValueType(ValueType.COORDINATE);
    item.setProgramStage(programStage);
    item.setProgram(programA);
    // When
    String columnSql = subject.getColumn(item);
    // Then
    assertThat(columnSql, is("(select \"" + dataElementA.getUid() + "\" from analytics_event_" + programA.getUid() + " where analytics_event_" + programA.getUid() + ".pi = ax.pi and \"" + dataElementA.getUid() + "\" is not null and ps = '" + programStage.getUid() + "' order by executiondate desc limit 1 )"));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 13 with BaseDimensionalItemObject

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

the class AbstractJdbcEventAnalyticsManagerTest method verifyGetSelectSqlWithTextDataElementIgnoringCase.

@Test
void verifyGetSelectSqlWithTextDataElementIgnoringCase() {
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    QueryItem item = new QueryItem(dio);
    item.setValueType(ValueType.TEXT);
    QueryFilter queryFilter = new QueryFilter(QueryOperator.IEQ, "IEQ");
    String column = subject.getSelectSql(queryFilter, item, from, to);
    assertThat(column, is("lower(ax.\"" + dataElementA.getUid() + "\")"));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) QueryFilter(org.hisp.dhis.common.QueryFilter) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 14 with BaseDimensionalItemObject

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

the class AbstractJdbcEventAnalyticsManagerTest method verifyGetCoordinateColumn.

@Test
void verifyGetCoordinateColumn() {
    // Given
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    QueryItem item = new QueryItem(dio);
    // When
    String column = subject.getCoordinateColumn(item);
    // Then
    String colName = quote(item.getItemName());
    assertThat(column, is("'[' || round(ST_X(" + colName + ")::numeric, 6) || ',' || round(ST_Y(" + colName + ")::numeric, 6) || ']' as " + colName));
    return;
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 15 with BaseDimensionalItemObject

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

the class AbstractJdbcEventAnalyticsManagerTest method verifyGetAggregateClauseWithValue.

@Test
void verifyGetAggregateClauseWithValue() {
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    EventQueryParams params = new EventQueryParams.Builder(createRequestParams()).withValue(dio).withAggregationType(AnalyticsAggregationType.SUM).build();
    String clause = subject.getAggregateClause(params);
    assertThat(clause, is("sum(ax.\"fWIAEtYVEGk\")"));
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Aggregations

BaseDimensionalItemObject (org.hisp.dhis.common.BaseDimensionalItemObject)21 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)17 Test (org.junit.jupiter.api.Test)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 QueryItem (org.hisp.dhis.common.QueryItem)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)3 QueryFilter (org.hisp.dhis.common.QueryFilter)3 DimensionalItemId (org.hisp.dhis.common.DimensionalItemId)2 RepeatableStageParams (org.hisp.dhis.common.RepeatableStageParams)2 ReportingRate (org.hisp.dhis.common.ReportingRate)2 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)2 ProgramDataElementDimensionItem (org.hisp.dhis.program.ProgramDataElementDimensionItem)2 ProgramTrackedEntityAttributeDimensionItem (org.hisp.dhis.program.ProgramTrackedEntityAttributeDimensionItem)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 DimensionResponse (org.hisp.dhis.analytics.dimension.DimensionResponse)1 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)1 ValueTypedDimensionalItemObject (org.hisp.dhis.common.ValueTypedDimensionalItemObject)1 DataElement (org.hisp.dhis.dataelement.DataElement)1