use of org.activityinfo.server.database.hibernate.entity.Indicator in project activityinfo by bedatadriven.
the class PieMapMarkerTest method testPies.
@Test
public void testPies() {
Dimension dimension = new Dimension(DimensionType.Indicator);
dimension.setCategoryColor(101, 255);
dimension.setCategoryColor(102, 0x00FF00);
dimension.setCategoryColor(103, 0x0000FF);
SiteDTO site1 = new SiteDTO();
site1.setId(1);
site1.setX(0d);
site1.setY(0d);
site1.setIndicatorValue(101, 50d);
site1.setIndicatorValue(102, 40d);
site1.setIndicatorValue(103, 10d);
List<SiteDTO> sites = new ArrayList<SiteDTO>();
sites.add(site1);
PiechartMapLayer layer = new PiechartMapLayer();
layer.addIndicatorId(101);
layer.addIndicatorId(102);
layer.addIndicatorId(103);
// layer.getColorDimensions().add(dimension);
MapReportElement mapElement = new MapReportElement();
mapElement.addLayer(layer);
MapContent content = new MapContent();
TiledMap map = new TiledMap(640, 480, new AiLatLng(0, 0), 6);
Map<Integer, Indicator> indicators = Maps.newHashMap();
indicators.put(101, new Indicator());
indicators.put(102, new Indicator());
indicators.put(103, new Indicator());
PiechartLayerGenerator generator = new PiechartLayerGenerator(layer, indicators);
generator.setSites(sites);
generator.generate(map, content);
Assert.assertEquals(1, content.getMarkers().size());
PieMapMarker marker = (PieMapMarker) content.getMarkers().get(0);
Assert.assertEquals(3, marker.getSlices().size());
}
use of org.activityinfo.server.database.hibernate.entity.Indicator in project activityinfo by bedatadriven.
the class EmptyChartsTest method generate.
@Test
public void generate() {
PivotChartReportElement element = new PivotChartReportElement(Type.StackedBar);
element.setIndicator(1);
element.addCategoryDimension(new Dimension(DimensionType.Partner));
element.addSeriesDimension(new Dimension(DimensionType.Database));
DispatcherSync dispatcher = createMock(DispatcherSync.class);
expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(Collections.EMPTY_LIST));
expect(dispatcher.execute(isA(GetDimensionLabels.class))).andReturn(new GetDimensionLabels.DimensionLabels(Collections.EMPTY_MAP));
replay(dispatcher);
IndicatorDAO indicatorDAO = createMock(IndicatorDAO.class);
expect(indicatorDAO.findById(eq(1))).andReturn(new Indicator());
replay(indicatorDAO);
PivotChartGenerator generator = new PivotChartGenerator(dispatcher, indicatorDAO);
generator.generate(new User(), element, new Filter(), new DateRange());
}
Aggregations