@Test public void testSelectDeselectFeature() { org.geomajas.layer.feature.Feature dto1 = new org.geomajas.layer.feature.Feature(); dto1.setId("feat1"); Feature feature1 = new Feature(dto1, layer1); org.geomajas.layer.feature.Feature dto2 = new org.geomajas.layer.feature.Feature(); dto2.setId("feat2"); Feature feature2 = new Feature(dto2, layer1); Assert.assertFalse(feature1.isSelected()); Assert.assertFalse(feature2.isSelected()); Assert.assertEquals(0, selectedCount); Assert.assertEquals(0, deselectedCount); Assert.assertNull(lastFeatureId); layer1.selectFeature(feature1); Assert.assertTrue(feature1.isSelected()); Assert.assertFalse(feature2.isSelected()); Assert.assertEquals(1, selectedCount); Assert.assertEquals(0, deselectedCount); Assert.assertEquals("feat1", lastFeatureId); lastFeatureId = null; layer1.selectFeature(feature2); Assert.assertTrue(feature1.isSelected()); Assert.assertTrue(feature2.isSelected()); Assert.assertEquals(2, selectedCount); Assert.assertEquals(0, deselectedCount); Assert.assertEquals("feat2", lastFeatureId); layer1.deselectFeature(feature1); Assert.assertFalse(feature1.isSelected()); Assert.assertTrue(feature2.isSelected()); Assert.assertEquals(2, selectedCount); Assert.assertEquals(1, deselectedCount); Assert.assertEquals("feat1", lastFeatureId); }
@Test public void testDeselectLayer() { org.geomajas.layer.feature.Feature dto1 = new org.geomajas.layer.feature.Feature(); dto1.setId("feat1"); Feature feature1 = new Feature(dto1, layer1); org.geomajas.layer.feature.Feature dto2 = new org.geomajas.layer.feature.Feature(); dto2.setId("feat2"); Feature feature2 = new Feature(dto2, layer1); Assert.assertFalse(feature1.isSelected()); Assert.assertFalse(feature2.isSelected()); Assert.assertEquals(0, selectedCount); Assert.assertEquals(0, deselectedCount); mapModel.selectLayer(layer1); Assert.assertFalse(feature1.isSelected()); Assert.assertFalse(feature2.isSelected()); Assert.assertEquals(0, selectedCount); Assert.assertEquals(0, deselectedCount); layer1.selectFeature(feature1); layer1.selectFeature(feature2); Assert.assertTrue(feature1.isSelected()); Assert.assertTrue(feature2.isSelected()); Assert.assertEquals(2, selectedCount); Assert.assertEquals(0, deselectedCount); mapModel.selectLayer(layer1); Assert.assertTrue(feature1.isSelected()); Assert.assertTrue(feature2.isSelected()); Assert.assertEquals(2, selectedCount); Assert.assertEquals(0, deselectedCount); mapModel.selectLayer(layer2); Assert.assertTrue(feature1.isSelected()); Assert.assertTrue(feature2.isSelected()); Assert.assertEquals(2, selectedCount); Assert.assertEquals(0, deselectedCount); }