@Test public void testFieldAggregations() throws ModelerException { ModelerWorkspaceHelper helper = new ModelerWorkspaceHelper(LOCALE); helper.autoModelFlat(workspace); helper.autoModelRelationalFlat(workspace); FieldMetaData firstField = workspace.getRelationalModel().get(0).get(0).get(0); assertEquals(firstField.getTextAggregationTypes(), firstField.getSelectedAggregations()); assertEquals(AggregationType.NONE, firstField.getDefaultAggregation()); firstField.setDefaultAggregation(AggregationType.COUNT); assertEquals(AggregationType.COUNT, firstField.getDefaultAggregation()); firstField.setSelectedAggregations(Arrays.asList(AggregationType.COUNT)); // Test Olap side assertEquals( workspace.getModel().getMeasures().get(0).getDefaultAggregation(), AggregationType.SUM); helper.populateDomain(workspace); // Now verify with the generated models LogicalModel logicalModel = workspace.getLogicalModel(ModelerPerspective.REPORTING); LogicalColumn lCol = logicalModel.getCategories().get(0).getLogicalColumns().get(0); assertEquals(firstField.getDefaultAggregation(), lCol.getAggregationType()); assertEquals(firstField.getSelectedAggregations(), lCol.getAggregationList()); List<OlapCube> cubes = (List<OlapCube>) workspace.getLogicalModel(ModelerPerspective.ANALYSIS).getProperty("olap_cubes"); OlapMeasure measure = cubes.get(0).getOlapMeasures().get(0); assertEquals(AggregationType.SUM, measure.getLogicalColumn().getAggregationType()); }