use of org.hisp.dhis.option.OptionSet in project dhis2-core by dhis2.
the class CsvMetadataImportTest method testOptionSetMerge.
@Test
void testOptionSetMerge() throws IOException {
// Import 1 OptionSet with 3 Options
ImportReport importReport = runImport("metadata/optionSet_add.csv", CsvImportClass.OPTION_SET);
assertEquals(4, importReport.getStats().getCreated());
// Send payload with 2 new Options
importReport = runImport("metadata/optionSet_update.csv", CsvImportClass.OPTION_SET, null, params -> params.setMergeMode(MergeMode.MERGE));
assertEquals(2, importReport.getStats().getCreated());
OptionSet optionSet = optionService.getOptionSetByCode("COLOR");
// Total 5 options added
assertEquals(5, optionSet.getOptions().size());
}
use of org.hisp.dhis.option.OptionSet in project dhis2-core by dhis2.
the class CsvMetadataImportTest method testOptionSetImport.
@Test
void testOptionSetImport() throws Exception {
ImportReport importReport = runImport("metadata/optionSets.csv", CsvImportClass.OPTION_SET, metadata -> {
assertEquals(4, metadata.getOptionSets().size());
assertEquals(3, metadata.getOptionSets().get(0).getOptions().size());
assertEquals(3, metadata.getOptionSets().get(1).getOptions().size());
assertEquals(3, metadata.getOptionSets().get(2).getOptions().size());
assertEquals(3, metadata.getOptionSets().get(3).getOptions().size());
});
assertEquals(16, importReport.getStats().getCreated());
List<OptionSet> optionSets = new ArrayList<>(optionService.getAllOptionSets());
assertEquals(4, optionSets.size());
assertEquals(3, optionSets.get(0).getOptions().size());
assertEquals(3, optionSets.get(1).getOptions().size());
assertEquals(3, optionSets.get(2).getOptions().size());
assertEquals(3, optionSets.get(3).getOptions().size());
}
use of org.hisp.dhis.option.OptionSet in project dhis2-core by dhis2.
the class BaseAnalyticalObjectTest method testPopulateAnalyticalProperties.
@Test
void testPopulateAnalyticalProperties() {
TrackedEntityAttribute tea = new TrackedEntityAttribute();
tea.setAutoFields();
tea.setValueType(ValueType.TEXT);
tea.setOptionSet(new OptionSet("name", ValueType.BOOLEAN));
TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension(tea, null, "EQ:10");
EventChart eventChart = new EventChart();
eventChart.setAutoFields();
eventChart.getColumnDimensions().add(tea.getUid());
eventChart.getAttributeDimensions().add(tead);
eventChart.populateAnalyticalProperties();
assertEquals(1, eventChart.getColumns().size());
DimensionalObject dim = eventChart.getColumns().get(0);
assertNotNull(dim);
assertEquals(DimensionType.PROGRAM_ATTRIBUTE, dim.getDimensionType());
assertEquals(AnalyticsType.EVENT, dim.getAnalyticsType());
assertEquals(tead.getFilter(), dim.getFilter());
assertEquals(tead.getAttribute().getValueType(), dim.getValueType());
assertEquals(tead.getAttribute().getOptionSet(), dim.getOptionSet());
}
use of org.hisp.dhis.option.OptionSet in project dhis2-core by dhis2.
the class QueryItemHelperTest method setUp.
@BeforeEach
void setUp() {
DataElement deA = createDataElement('A');
Option opA = createOption('A');
Option opB = createOption('B');
opA.setUid(UID_A);
opB.setUid(UID_B);
OptionSet os = createOptionSet('A', opA, opB);
Legend lpA = createLegend('A', 0.0, 1.0);
lpA.setCode(LEGEND_CODE_A);
Legend lpB = createLegend('B', 0.0, 1.0);
lpB.setCode(LEGEND_CODE_B);
lpA.setUid(UID_A);
lpB.setUid(UID_B);
LegendSet ls = createLegendSet('A', lpA, lpB);
queryItem = new QueryItem(deA, ls, deA.getValueType(), deA.getAggregationType(), os);
}
use of org.hisp.dhis.option.OptionSet in project dhis2-core by dhis2.
the class EventQueryValidatorTest method setUpTest.
@Override
public void setUpTest() {
queryValidator = new DefaultEventQueryValidator(aggregateQueryValidator, systemSettingManager);
prA = createProgram('A');
prB = createProgram('B');
idObjectManager.save(prA);
idObjectManager.save(prB);
deA = createDataElement('A', ValueType.INTEGER, AggregationType.SUM, DataElementDomain.TRACKER);
deB = createDataElement('B', ValueType.INTEGER, AggregationType.SUM, DataElementDomain.TRACKER);
deC = createDataElement('C', ValueType.INTEGER, AggregationType.AVERAGE_SUM_ORG_UNIT, DataElementDomain.TRACKER);
deD = createDataElement('D', ValueType.INTEGER, AggregationType.AVERAGE_SUM_ORG_UNIT, DataElementDomain.TRACKER);
deE = createDataElement('E', ValueType.COORDINATE, AggregationType.NONE, DataElementDomain.TRACKER);
idObjectManager.save(deA);
idObjectManager.save(deB);
idObjectManager.save(deC);
idObjectManager.save(deD);
idObjectManager.save(deE);
atA = createTrackedEntityAttribute('A');
atB = createTrackedEntityAttribute('B');
idObjectManager.save(atA);
idObjectManager.save(atB);
ouA = createOrganisationUnit('A');
ouB = createOrganisationUnit('B', ouA);
ouC = createOrganisationUnit('C', ouA);
organisationUnitService.addOrganisationUnit(ouA);
organisationUnitService.addOrganisationUnit(ouB);
organisationUnitService.addOrganisationUnit(ouC);
lsA = createLegendSet('A');
idObjectManager.save(lsA);
osA = new OptionSet("OptionSetA", ValueType.TEXT);
idObjectManager.save(osA);
}
Aggregations