dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09360
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2464: (GIS) Fixed bug when getting the MapLegend by name. Unit tests for MappingServiceTest. Done.
------------------------------------------------------------
revno: 2464
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-06 11:10:29 +0700
message:
(GIS) Fixed bug when getting the MapLegend by name. Unit tests for MappingServiceTest. Done.
modified:
dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java
dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2010-11-29 15:44:01 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2011-01-06 04:10:29 +0000
@@ -93,7 +93,7 @@
{
Session session = sessionFactory.getCurrentSession();
- Criteria criteria = session.createCriteria( MapLegendSet.class );
+ Criteria criteria = session.createCriteria( MapLegend.class );
criteria.add( Restrictions.eq( "name", name ) );
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2011-01-04 09:54:15 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2011-01-06 04:10:29 +0000
@@ -30,9 +30,13 @@
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.assertNotNull;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.dataelement.DataElement;
@@ -71,7 +75,7 @@
private Indicator indicator;
private DataElement dataElement;
-
+
private DataElementGroup dataElementGroup;
private PeriodType periodType;
@@ -114,7 +118,7 @@
dataElement = createDataElement( 'A' );
dataElementService.addDataElement( dataElement );
-
+
dataElementGroup = createDataElementGroup( 'A' );
dataElementGroup.getMembers().add( dataElement );
dataElementService.addDataElementGroup( dataElementGroup );
@@ -128,6 +132,203 @@
}
// -------------------------------------------------------------------------
+ // MapLegend
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void testGetAddOrUpdateMapLegendByName()
+ {
+ MapLegend legend = createMapLegend( 'A', 0.1, 0.2 );
+
+ mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), legend.getEndValue(), legend
+ .getColor() );
+
+ legend = mappingService.getMapLegendByName( legend.getName() );
+
+ assertNotNull( legend );
+
+ int id = legend.getId();
+
+ mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), 0.3, "ColorB" );
+
+ assertEquals( "MapLegendA", mappingService.getMapLegend( id ).getName() );
+ assertEquals( 0.1, mappingService.getMapLegend( id ).getStartValue() );
+ assertEquals( 0.3, mappingService.getMapLegend( id ).getEndValue() );
+ assertEquals( "ColorB", mappingService.getMapLegend( id ).getColor() );
+ }
+
+ @Test
+ public void testDeleteMapLegend()
+ {
+ MapLegend legend = createMapLegend( 'A', 0.1, 0.2 );
+
+ mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), legend.getEndValue(), legend
+ .getColor() );
+
+ legend = mappingService.getMapLegendByName( legend.getName() );
+
+ assertNotNull( legend );
+
+ int id = legend.getId();
+
+ mappingService.deleteMapLegend( legend );
+
+ assertNull( mappingService.getMapLegend( id ) );
+ }
+
+ @Test
+ public void testGetAllMapLegends()
+ {
+ MapLegend legend1 = createMapLegend( 'A', 0.1, 0.2 );
+ MapLegend legend2 = createMapLegend( 'B', 0.3, 0.4 );
+ MapLegend legend3 = createMapLegend( 'C', 0.5, 0.6 );
+
+ mappingService.addOrUpdateMapLegend( legend1.getName(), legend1.getStartValue(), legend1.getEndValue(), legend1
+ .getColor() );
+ mappingService.addOrUpdateMapLegend( legend3.getName(), legend3.getStartValue(), legend3.getEndValue(), legend3
+ .getColor() );
+
+ legend1 = mappingService.getMapLegendByName( legend1.getName() );
+ legend3 = mappingService.getMapLegendByName( legend3.getName() );
+
+ assertNotNull( legend1 );
+ assertNotNull( legend3 );
+
+ int idA = legend1.getId();
+ int idC = legend3.getId();
+
+ assertEquals( legend1, mappingService.getMapLegend( idA ) );
+ assertEquals( legend3, mappingService.getMapLegend( idC ) );
+ assertTrue( !mappingService.getAllMapLegends().contains( legend2 ) );
+ }
+
+ // -------------------------------------------------------------------------
+ // MapLegendSet
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void testAddGetMapLegendSet()
+ {
+ MapLegendSet legendSet = createMapLegendSet( 'B', indicator );
+
+ int id = mappingService.addMapLegendSet( legendSet );
+
+ assertNotNull( mappingService.getMapLegendSet( id ) );
+ }
+
+ @Test
+ public void testGetUpdateMapLegendSetByName()
+ {
+ MapLegendSet legendSet = createMapLegendSet( 'C', indicator );
+
+ int id = mappingService.addMapLegendSet( legendSet );
+
+ legendSet = mappingService.getMapLegendSet( id );
+
+ assertNotNull( legendSet );
+
+ legendSet.setName( "MapLegendSetB" );
+ legendSet.setColorLow( "ColorLowB" );
+ legendSet.setColorHigh( "ColorHighB" );
+
+ mappingService.updateMapLegendSet( legendSet );
+
+ assertEquals( "MapLegendSetB", mappingService.getMapLegendSetByName( "MapLegendSetB" ).getName() );
+ assertEquals( "ColorLowB", mappingService.getMapLegendSetByName( "MapLegendSetB" ).getColorLow() );
+ assertEquals( "ColorHighB", mappingService.getMapLegendSetByName( "MapLegendSetB" ).getColorHigh() );
+ }
+
+ @Test
+ public void testGetMapLegendSetsByType()
+ {
+ MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
+ MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
+ MapLegendSet legendSet3 = createMapLegendSet( 'D', indicator );
+
+ legendSet1.setType( MappingService.MAPLEGENDSET_TYPE_AUTOMATIC );
+ legendSet2.setType( MappingService.MAPLEGENDSET_TYPE_PREDEFINED );
+ legendSet3.setType( MappingService.MAPLEGENDSET_TYPE_PREDEFINED );
+
+ int idA = mappingService.addMapLegendSet( legendSet1 );
+ int idB = mappingService.addMapLegendSet( legendSet2 );
+ int idC = mappingService.addMapLegendSet( legendSet3 );
+
+ List<MapLegendSet> autoTypes = new ArrayList<MapLegendSet>( mappingService
+ .getMapLegendSetsByType( MappingService.MAPLEGENDSET_TYPE_AUTOMATIC ) );
+
+ List<MapLegendSet> predefinedTypes = new ArrayList<MapLegendSet>( mappingService
+ .getMapLegendSetsByType( MappingService.MAPLEGENDSET_TYPE_PREDEFINED ) );
+
+ assertTrue( autoTypes.contains( mappingService.getMapLegendSet( idA ) ) );
+ assertTrue( !autoTypes.contains( mappingService.getMapLegendSet( idB ) ) );
+ assertTrue( !autoTypes.contains( mappingService.getMapLegendSet( idC ) ) );
+ assertTrue( predefinedTypes.contains( mappingService.getMapLegendSet( idB ) ) );
+ assertTrue( predefinedTypes.contains( mappingService.getMapLegendSet( idC ) ) );
+ assertTrue( !predefinedTypes.contains( mappingService.getMapLegendSet( idA ) ) );
+
+ }
+
+ @Test
+ public void testGetMapLegendSetByIndicatorOrDataElement()
+ {
+ MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
+ MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
+
+ int idB = mappingService.addMapLegendSet( legendSet1 );
+ int idC = mappingService.addMapLegendSet( legendSet2 );
+
+ assertEquals("1", mapLegendSet, mappingService.getMapLegendSetByIndicator( indicator.getId() ) );
+
+ legendSet1 = mappingService.getMapLegendSet( idB );
+ legendSet2 = mappingService.getMapLegendSet( idC );
+
+ legendSet1.getDataElements().add( dataElement );
+ legendSet2.getDataElements().add( dataElement );
+
+ mappingService.updateMapLegendSet( legendSet1 );
+ mappingService.updateMapLegendSet( legendSet2 );
+
+ assertEquals("2", mappingService.getMapLegendSet( idB ), mappingService.getMapLegendSetByDataElement( dataElement.getId() ) );
+
+ }
+
+ @Test
+ public void testGetAllMapLegendSets()
+ {
+ MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
+ MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
+ MapLegendSet legendSet3 = createMapLegendSet( 'D', indicator );
+
+ Collection<MapLegendSet> mapLegendSets = new HashSet<MapLegendSet>();
+
+ mapLegendSets.add( mapLegendSet );
+ mapLegendSets.add( legendSet1 );
+ mapLegendSets.add( legendSet2 );
+ mapLegendSets.add( legendSet3 );
+
+ mappingService.addMapLegendSet( legendSet1 );
+ mappingService.addMapLegendSet( legendSet2 );
+ mappingService.addMapLegendSet( legendSet3 );
+
+ assertTrue( mappingService.getAllMapLegendSets().containsAll( mapLegendSets ) );
+
+ }
+
+ @Test
+ public void testIndicatorHasMapLegendSet()
+ {
+ MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
+ MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
+ MapLegendSet legendSet3 = createMapLegendSet( 'D', indicator );
+
+ mappingService.addMapLegendSet( legendSet1 );
+ mappingService.addMapLegendSet( legendSet2 );
+ mappingService.addMapLegendSet( legendSet3 );
+
+ assertTrue( mappingService.indicatorHasMapLegendSet( indicator.getId() ) );
+ }
+
+ // -------------------------------------------------------------------------
// MapView tests
// -------------------------------------------------------------------------
@@ -135,10 +336,9 @@
public void testAddGetMapView()
{
MapView mapView = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
- MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit,
- organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
- "1", "1", 1 );
+ MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
+ MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
int idA = mappingService.addMapView( mapView );
@@ -153,82 +353,79 @@
public void testGetDeleteMapViewByName()
{
MapView mapView = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
- MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit,
- organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
- "1", "1", 1 );
+ MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
+ MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
int id = mappingService.addMapView( mapView );
-
+
mapView = mappingService.getMapViewByName( "MapViewA" );
-
+
mappingService.deleteMapView( mapView );
-
+
assertNull( mappingService.getMapView( id ) );
}
-
+
@Test
public void testGetAllMapViews()
{
MapView mapView1 = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
- MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit,
- organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
- "1", "1", 1 );
-
+ MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
+ MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
+
MapView mapView2 = new MapView( "MapViewB", OrganisationUnit.FEATURETYPE_POLYGON,
- MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
+ MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
"2", "2", 1 );
mappingService.addMapView( mapView1 );
mappingService.addMapView( mapView2 );
-
+
assertEquals( 2, mappingService.getAllMapViews().size() );
}
-
-
+
@Test
public void testGetMapViewsByFeatureType()
{
MapView mapView1 = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
- MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit,
- organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
- "1", "1", 1 );
-
+ MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
+ MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
+
MapView mapView2 = new MapView( "MapViewB", OrganisationUnit.FEATURETYPE_POLYGON,
- MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
+ MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
"2", "2", 1 );
-
+
MapView mapView3 = new MapView( "MapViewC", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
- MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup,
- dataElement, MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
+ MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
+ MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
"3", "3", 1 );
mappingService.addMapView( mapView1 );
mappingService.addMapView( mapView2 );
mappingService.addMapView( mapView3 );
-
+
assertEquals( 1, mappingService.getMapViewsByFeatureType( OrganisationUnit.FEATURETYPE_POLYGON ).size() );
assertEquals( 2, mappingService.getMapViewsByFeatureType( OrganisationUnit.FEATURETYPE_MULTIPOLYGON ).size() );
}
-
+
// -------------------------------------------------------------------------
// MapLayer
// -------------------------------------------------------------------------
-
+
@Test
public void testAddGetMapLayer()
{
- MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "A", 0.1, "B", 1);
-
+ MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "A", 0.1, "B",
+ 1 );
+
int id = mappingService.addMapLayer( mapLayer );
-
+
assertEquals( "MapLayerA", mappingService.getMapLayer( id ).getName() );
assertEquals( MappingService.MAP_LAYER_TYPE_BASELAYER, mappingService.getMapLayer( id ).getType() );
assertEquals( "A", mappingService.getMapLayer( id ).getFillColor() );
@@ -236,78 +433,86 @@
assertEquals( 0.1, mappingService.getMapLayer( id ).getFillOpacity() );
assertEquals( 1, mappingService.getMapLayer( id ).getStrokeWidth() );
}
-
+
@Test
public void testGetUpdateDeleteMapLayerByName()
{
- MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "A", 0.1, "B", 1);
-
+ MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "A", 0.1, "B",
+ 1 );
+
int id = mappingService.addMapLayer( mapLayer );
-
+
mapLayer = mappingService.getMapLayer( id );
-
+
mapLayer.setName( "MapLayerB" );
mapLayer.setFillOpacity( 0.05 );
mapLayer.setStrokeWidth( 0 );
-
+
mappingService.updateMapLayer( mapLayer );
-
- assertEquals( "MapLayerB", mappingService.getMapLayerByName( "MapLayerB" ).getName() );
+
+ assertEquals( "MapLayerB", mappingService.getMapLayerByName( "MapLayerB" ).getName() );
assertEquals( 0.05, mappingService.getMapLayerByName( "MapLayerB" ).getFillOpacity() );
assertEquals( 0, mappingService.getMapLayerByName( "MapLayerB" ).getStrokeWidth() );
}
-
+
@Test
public void testGetAllMapLayers()
{
- MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceA", "layerA", "A", 0.1, "B", 1);
- MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "A", 0.1, "B", 1);
- MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceC", "layerC", "C", 0.1, "D", 2);
- MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceD", "layerA", "C", 0.1, "D", 2);
-
+ MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceA",
+ "layerA", "A", 0.1, "B", 1 );
+ MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "A", 0.1, "B", 1 );
+ MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceC", "layerC",
+ "C", 0.1, "D", 2 );
+ MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceD",
+ "layerA", "C", 0.1, "D", 2 );
+
int idA = mappingService.addMapLayer( mapLayer1 );
int idB = mappingService.addMapLayer( mapLayer2 );
int idC = mappingService.addMapLayer( mapLayer3 );
-
+
assertEquals( mapLayer1, mappingService.getMapLayer( idA ) );
assertEquals( mapLayer2, mappingService.getMapLayer( idB ) );
assertEquals( mapLayer3, mappingService.getMapLayer( idC ) );
assertTrue( !mappingService.getAllMapLayers().contains( mapLayer4 ) );
}
-
+
@Test
public void testGetMapLayersByTypeOrMapSource()
{
List<MapLayer> baseLayers = new ArrayList<MapLayer>();
List<MapLayer> overlayLayers = new ArrayList<MapLayer>();
-
- MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceA", "layerA", "A", 0.1, "B", 1);
- MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceB", "", "A", 0.1, "B", 1);
- MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceC", "layerC", "C", 0.1, "D", 2);
- MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceD", "layerA", "C", 0.1, "D", 2);
-
+
+ MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceA",
+ "layerA", "A", 0.1, "B", 1 );
+ MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceB", "", "A",
+ 0.1, "B", 1 );
+ MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "mapSourceC", "layerC",
+ "C", 0.1, "D", 2 );
+ MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "mapSourceD",
+ "layerA", "C", 0.1, "D", 2 );
+
baseLayers.add( mapLayer1 );
baseLayers.add( mapLayer4 );
-
+
overlayLayers.add( mapLayer2 );
overlayLayers.add( mapLayer3 );
-
+
int idA = mappingService.addMapLayer( mapLayer1 );
int idB = mappingService.addMapLayer( mapLayer2 );
int idC = mappingService.addMapLayer( mapLayer3 );
int idD = mappingService.addMapLayer( mapLayer4 );
-
+
assertEquals( baseLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_BASELAYER ) );
assertEquals( overlayLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_OVERLAY ) );
-
+
assertEquals( mappingService.getMapLayer( idA ), mappingService.getMapLayerByMapSource( "mapSourceA" ) );
assertEquals( mappingService.getMapLayer( idB ), mappingService.getMapLayerByMapSource( "mapSourceB" ) );
assertEquals( mappingService.getMapLayer( idC ), mappingService.getMapLayerByMapSource( "mapSourceC" ) );
assertEquals( mappingService.getMapLayer( idD ), mappingService.getMapLayerByMapSource( "mapSourceD" ) );
}
-
+
// -------------------------------------------------------------------------
// Map value tests
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2011-01-04 04:11:22 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2011-01-06 04:10:29 +0000
@@ -70,6 +70,7 @@
import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.mapping.MapLegend;
import org.hisp.dhis.mapping.MapLegendSet;
import org.hisp.dhis.mapping.MappingService;
import org.hisp.dhis.olap.OlapURL;
@@ -832,6 +833,18 @@
return importDataValue;
}
+
+ public static MapLegend createMapLegend( char uniqueCharacter, Double startValue, Double endValue )
+ {
+ MapLegend legend = new MapLegend();
+
+ legend.setName( "MapLegend" + uniqueCharacter );
+ legend.setStartValue( startValue );
+ legend.setEndValue( endValue );
+ legend.setColor( "Color" + uniqueCharacter );
+
+ return legend;
+ }
public static MapLegendSet createMapLegendSet( char uniqueCharacter, Indicator... indicators )
{