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())));
}
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()));
}
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()));
}
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()));
}
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())));
}
Aggregations