@Test
  public void testServerSideOnlyInfo() throws Exception {
    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("appServerSideOnly");
    request.setMapId("mapServerSideOnly");
    GetMapConfigurationResponse response =
        (GetMapConfigurationResponse)
            dispatcher.execute(GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);

    // user data
    ClientUserDataInfo info = mapInfo.getUserData();
    Assert.assertNull(info);

    // widget data
    Assert.assertNotNull(mapInfo.getWidgetInfo());
    Assert.assertNull(mapInfo.getWidgetInfo("appDummy")); // not present
    Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree")); // present
    Assert.assertNull(mapInfo.getWidgetInfo("mapDummy")); // filtered because ServerSideOnlyInfo

    // ViewBounds LimitOption
    Assert.assertEquals(
        BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS, mapInfo.getViewBoundsLimitOption());
  }
  @Before
  public void setUp() {
    ClientMapInfo info = new ClientMapInfo();
    info.setCrs("EPSG:4326");
    info.setInitialBounds(new Bbox(0, 0, 180, 180));
    mapModel = new MapModel(info);

    VectorLayerInfo serverLayerInfo1 = new VectorLayerInfo();
    ClientVectorLayerInfo layerInfo1 = new ClientVectorLayerInfo();
    layerInfo1.setLayerInfo(serverLayerInfo1);
    layerInfo1.setMaxExtent(new Bbox(0, 0, 200, 100));
    layerInfo1.setId("layer1");
    layerInfo1.setServerLayerId("layer1");
    layer1 = new VectorLayer(mapModel, layerInfo1);

    VectorLayerInfo serverLayerInfo2 = new VectorLayerInfo();
    ClientVectorLayerInfo layerInfo2 = new ClientVectorLayerInfo();
    layerInfo2.setLayerInfo(serverLayerInfo2);
    layerInfo2.setMaxExtent(new Bbox(0, 0, 250, 125));
    layerInfo2.setId("layer2");
    layerInfo2.setServerLayerId("layer2");
    layer2 = new VectorLayer(mapModel, layerInfo2);

    mapModel.getLayers().add(layer1);
    mapModel.getLayers().add(layer2);

    selectedCount = 0;
    deselectedCount = 0;
    lastFeatureId = null;
    layer1.addFeatureSelectionHandler(
        new FeatureSelectionHandler() {
          public void onFeatureSelected(FeatureSelectedEvent event) {
            selectedCount++;
            lastFeatureId = event.getFeature().getId();
          }

          public void onFeatureDeselected(FeatureDeselectedEvent event) {
            deselectedCount++;
            lastFeatureId = event.getFeature().getId();
          }
        });
  }
  @Test
  public void testViewBoundsLimitOption() throws Exception {
    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("vectorsMapWithViewBoundsOption");
    request.setMapId("viewBoundsLimitTestMap");
    GetMapConfigurationResponse response =
        (GetMapConfigurationResponse)
            dispatcher.execute(GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);

    // ViewBounds LimitOption
    BoundsLimitOption boundsLimitOption = mapInfo.getViewBoundsLimitOption();
    Assert.assertNotNull(boundsLimitOption);
    Assert.assertEquals(BoundsLimitOption.CENTER_WITHIN_MAX_BOUNDS, boundsLimitOption);
  }
  @Test
  public void testConvertMaxExtent() throws Exception {
    Layer layer = configurationService.getLayer("countries");
    Bbox configMaxExtent = layer.getLayerInfo().getMaxExtent();
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("simplevectors");
    request.setMapId("coordTestMap");
    GetMapConfigurationResponse response =
        (GetMapConfigurationResponse)
            dispatcher.execute(GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);
    Bbox mapMaxExtent = mapInfo.getLayers().get(0).getMaxExtent();
    // these values were registered during a first run, they have *not* been externally verified
    Assert.assertEquals(-9467848.347161204, mapMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-2.0037508342789236E7, mapMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(1.8935696632026553E7, mapMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(4.007501596344786E7, mapMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    // user data
    ClientUserDataInfo info = mapInfo.getUserData();
    Assert.assertNotNull(info);
    Assert.assertTrue(info instanceof ClientApplicationInfo.DummyClientUserDataInfo);
    Assert.assertEquals(
        "some data", ((ClientApplicationInfo.DummyClientUserDataInfo) info).getDummy());

    // widget data
    Assert.assertNotNull(mapInfo.getWidgetInfo());
    Assert.assertNull(mapInfo.getWidgetInfo("mapSelect"));
    Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree"));
    Assert.assertEquals(
        "layer1, layer2",
        ((ClientApplicationInfo.DummyClientWidgetInfo) mapInfo.getWidgetInfo("layerTree"))
            .getDummy());
    // Default value of ViewBounds LimitOption
    BoundsLimitOption boundsLimitOption = mapInfo.getViewBoundsLimitOption();
    Assert.assertNotNull(info);
    Assert.assertEquals(BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS, boundsLimitOption);
  }