Search in sources :

Example 41 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputIdSchemeIsSetToName.

@Test
void testGetSchemeIdResponseMapWhenOutputIdSchemeIsSetToName() {
    // Given
    final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
    final OrganisationUnit orUnitStub = stubOrgUnit();
    final Period periodStub = stubPeriod();
    final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub);
    theDataQueryParams.setOutputIdScheme(NAME);
    // When
    final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
    // Then
    final String orgUnitUid = orUnitStub.getUid();
    final String periodIsoDate = periodStub.getIsoDate();
    final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
    final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
    final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
    assertThat(responseMap.get(orgUnitUid), is(equalTo(orUnitStub.getName())));
    assertThat(responseMap.get(periodIsoDate), is(equalTo(periodStub.getName())));
    assertThat(responseMap.get(dataElementA.getUid()), is(equalTo(dataElementA.getName())));
    assertThat(responseMap.get(dataElementB.getUid()), is(equalTo(dataElementB.getName())));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(equalTo(categoryOptionComboC.getName())));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(equalTo(categoryOptionComboC.getName())));
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataElement(org.hisp.dhis.dataelement.DataElement) Period(org.hisp.dhis.period.Period) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) PeriodType.getPeriodFromIsoString(org.hisp.dhis.period.PeriodType.getPeriodFromIsoString) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test)

Example 42 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputOrgUnitIdSchemeIsSetToUidForDataValueSet.

@Test
void testGetSchemeIdResponseMapWhenOutputOrgUnitIdSchemeIsSetToUidForDataValueSet() {
    // Given
    final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
    final OrganisationUnit orUnitStub = stubOrgUnit();
    final Period periodStub = stubPeriod();
    final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub, DATA_VALUE_SET);
    theDataQueryParams.setOutputOrgUnitIdScheme(UID);
    // When
    final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
    // Then
    final String orgUnitUid = orUnitStub.getUid();
    final String periodIsoDate = periodStub.getIsoDate();
    final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
    final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
    final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
    assertThat(responseMap.get(orgUnitUid), is(equalTo(orUnitStub.getUid())));
    assertThat(responseMap.get(periodIsoDate), is(equalTo(periodStub.getUid())));
    assertThat(responseMap.get(dataElementA.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(dataElementB.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataElement(org.hisp.dhis.dataelement.DataElement) Period(org.hisp.dhis.period.Period) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) PeriodType.getPeriodFromIsoString(org.hisp.dhis.period.PeriodType.getPeriodFromIsoString) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test)

Example 43 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputIdSchemeIsSetToUuid.

@Test
void testGetSchemeIdResponseMapWhenOutputIdSchemeIsSetToUuid() {
    // Given
    final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
    final OrganisationUnit orUnitStub = stubOrgUnit();
    final Period periodStub = stubPeriod();
    final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub);
    theDataQueryParams.setOutputIdScheme(UUID);
    // When
    final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
    // Then
    final String orgUnitUid = orUnitStub.getUid();
    final String periodIsoDate = periodStub.getIsoDate();
    final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
    final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
    final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
    assertThat(responseMap.get(orgUnitUid), is(emptyOrNullString()));
    assertThat(responseMap.get(periodIsoDate), is(emptyOrNullString()));
    assertThat(responseMap.get(dataElementA.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(dataElementB.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataElement(org.hisp.dhis.dataelement.DataElement) Period(org.hisp.dhis.period.Period) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) PeriodType.getPeriodFromIsoString(org.hisp.dhis.period.PeriodType.getPeriodFromIsoString) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test)

Example 44 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputDataElementIdSchemeIsSetToUuidForDataValueSet.

@Test
void testGetSchemeIdResponseMapWhenOutputDataElementIdSchemeIsSetToUuidForDataValueSet() {
    // Given
    final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
    final OrganisationUnit orUnitStub = stubOrgUnit();
    final Period periodStub = stubPeriod();
    final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub, DATA_VALUE_SET);
    theDataQueryParams.setOutputDataElementIdScheme(UUID);
    // When
    final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
    // Then
    final String orgUnitUid = orUnitStub.getUid();
    final String periodIsoDate = periodStub.getIsoDate();
    final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
    final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
    final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
    assertThat(responseMap.get(orgUnitUid), is(equalTo(orUnitStub.getUid())));
    assertThat(responseMap.get(periodIsoDate), is(equalTo(periodStub.getUid())));
    assertThat(responseMap.get(dataElementA.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(dataElementB.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataElement(org.hisp.dhis.dataelement.DataElement) Period(org.hisp.dhis.period.Period) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) PeriodType.getPeriodFromIsoString(org.hisp.dhis.period.PeriodType.getPeriodFromIsoString) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test)

Example 45 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputOrgUnitIdSchemeOverridesOutputOrgUnitIdSchemeForDataValueSet.

@Test
void testGetSchemeIdResponseMapWhenOutputOrgUnitIdSchemeOverridesOutputOrgUnitIdSchemeForDataValueSet() {
    // Given
    final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
    final OrganisationUnit orUnitStub = stubOrgUnit();
    final Period periodStub = stubPeriod();
    final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub, DATA_VALUE_SET);
    theDataQueryParams.setOutputIdScheme(NAME);
    // Overriding output id schema and setting CODE for Org Unit
    theDataQueryParams.setOutputOrgUnitIdScheme(CODE);
    // When
    final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
    // Then
    final String orgUnitUid = orUnitStub.getUid();
    final String periodIsoDate = periodStub.getIsoDate();
    final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
    final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
    final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
    assertThat(responseMap.get(orgUnitUid), is(equalTo(orUnitStub.getCode())));
    assertThat(responseMap.get(periodIsoDate), is(equalTo(periodStub.getName())));
    assertThat(responseMap.get(dataElementA.getUid()), is(equalTo(dataElementA.getName())));
    assertThat(responseMap.get(dataElementB.getUid()), is(equalTo(dataElementB.getName())));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(equalTo(categoryOptionComboC.getName())));
    assertThat(responseMap.get(categoryOptionComboC.getUid()), is(equalTo(categoryOptionComboC.getName())));
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataElement(org.hisp.dhis.dataelement.DataElement) Period(org.hisp.dhis.period.Period) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) PeriodType.getPeriodFromIsoString(org.hisp.dhis.period.PeriodType.getPeriodFromIsoString) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test)

Aggregations

CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)218 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)94 DataElement (org.hisp.dhis.dataelement.DataElement)68 Period (org.hisp.dhis.period.Period)67 Test (org.junit.jupiter.api.Test)58 CategoryCombo (org.hisp.dhis.category.CategoryCombo)52 CategoryOption (org.hisp.dhis.category.CategoryOption)51 ArrayList (java.util.ArrayList)39 Program (org.hisp.dhis.program.Program)31 DataValue (org.hisp.dhis.datavalue.DataValue)30 Collectors (java.util.stream.Collectors)26 Category (org.hisp.dhis.category.Category)26 Date (java.util.Date)25 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)25 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)23 CategoryService (org.hisp.dhis.category.CategoryService)20 DataSet (org.hisp.dhis.dataset.DataSet)20 ProgramStage (org.hisp.dhis.program.ProgramStage)20 Event (org.hisp.dhis.tracker.domain.Event)20 ProgramInstance (org.hisp.dhis.program.ProgramInstance)16