MapContent { public List<Layer> layers() { monitor.readLock().lock(); try { return layerList; } finally { monitor.readLock().unlock(); } } MapContent();  MapContent(MapContext context); @Deprecated  MapContent(CoordinateReferenceSystem crs); @Deprecated  MapContent(MapLayer[] array); @Deprecated  MapContent(MapLayer[] array, CoordinateReferenceSystem crs); @Deprecated  MapContent(MapLayer[] array, String title, String contextAbstract, String contactInformation,
            String[] keywords); @Deprecated  MapContent(MapLayer[] array, String title, String contextAbstract, String contactInformation,
            String[] keywords, final CoordinateReferenceSystem crs); void dispose(); void addMapLayerListListener(MapLayerListListener listener); void removeMapLayerListListener(MapLayerListListener listener); boolean addLayer(Layer layer); int addLayers(Collection<? extends Layer> layers); boolean removeLayer(Layer layer); void moveLayer(int sourcePosition, int destPosition); List<Layer> layers(); ReferencedEnvelope getMaxBounds(); MapViewport getViewport(); void setViewport(MapViewport viewport); void addMapBoundsListener(MapBoundsListener listener); void removeMapBoundsListener(MapBoundsListener listener); CoordinateReferenceSystem getCoordinateReferenceSystem(); void addPropertyChangeListener(java.beans.PropertyChangeListener listener); void removePropertyChangeListener(java.beans.PropertyChangeListener listener); java.util.Map<String, Object> getUserData(); String getTitle(); void setTitle(String title);  }
@Test public void addingLayerViaLayersListFiresEvent() throws Exception { listener.setExpected(WaitingMapListener.Type.ADDED); mapContent.layers().add(new MockLayer(WORLD)); listener.await(WaitingMapListener.Type.ADDED, LISTENER_TIMEOUT); }
@Test public void removeLayerViaLayerListByPosition() throws Exception { MockLayer layer1 = new MockLayer(WORLD); mapContent.layers().add(layer1); MockLayer layer2 = new MockLayer(WORLD); mapContent.layers().add(layer2); mapContent.layers().remove(0); assertEquals(1, mapContent.layers().size()); assertTrue(mapContent.layers().get(0) == layer2); assertTrue(layer1.isDisposed()); assertFalse(layer2.isDisposed()); }
@Test public void removeLayerViaLayerListByReference() throws Exception { MockLayer layer1 = new MockLayer(WORLD); mapContent.layers().add(layer1); MockLayer layer2 = new MockLayer(WORLD); mapContent.layers().add(layer2); mapContent.layers().remove(layer1); assertEquals(1, mapContent.layers().size()); assertTrue(mapContent.layers().get(0) == layer2); assertTrue(layer1.isDisposed()); assertFalse(layer2.isDisposed()); }
@Test(expected=ArrayIndexOutOfBoundsException.class) public void removeLayerIndexOutOfRangeThrowsException() throws Exception { mapContent.layers().add(new MockLayer(WORLD)); mapContent.layers().remove(1); }
@Test public void removeLayerNotInListReturnsFalse() throws Exception { assertFalse( mapContent.layers().remove(new MockLayer(WORLD)) ); }
@Test(expected=UnsupportedOperationException.class) public void addingLayerViaListIteratorIsNotSupported() throws Exception { ListIterator<Layer> listIterator = mapContent.layers().listIterator(); listIterator.add(new MockLayer(WORLD)); }