### Question:
DefaultMapContext extends MapContext { @SuppressWarnings("deprecation") public boolean addLayer(int index, MapLayer mapLayer) { Layer layer = mapLayer.toLayer(); layers().add(index, layer); return true; } DefaultMapContext();  DefaultMapContext(final CoordinateReferenceSystem crs);  DefaultMapContext(MapLayer[] layers);  DefaultMapContext(MapLayer[] layers, final CoordinateReferenceSystem crs);  DefaultMapContext(MapLayer[] layers, String title, String contextAbstract,
            String contactInformation, String[] keywords);  DefaultMapContext(MapLayer[] layers, String title, String contextAbstract,
            String contactInformation, String[] keywords, final CoordinateReferenceSystem crs); @SuppressWarnings("deprecation") boolean addLayer(int index, MapLayer mapLayer); @SuppressWarnings("deprecation") boolean addLayer(MapLayer mapLayer); void addLayer(FeatureSource featureSource, Style style); void addLayer(CollectionSource source, Style style); void addLayer(GridCoverage gc, Style style); void addLayer(AbstractGridCoverage2DReader reader, Style style); void addLayer(FeatureCollection featureCollection, Style style); @SuppressWarnings("unchecked") void addLayer(Collection collection, Style style); boolean removeLayer(MapLayer layer); MapLayer removeLayer(int index); @SuppressWarnings("deprecation") int addLayers(MapLayer[] array); void removeLayers(MapLayer[] array); @SuppressWarnings("deprecation") MapLayer[] getLayers(); @SuppressWarnings("deprecation") MapLayer getLayer(int index); ReferencedEnvelope getAreaOfInterest(); void clearLayerList(); @Override synchronized MapViewport getViewport();  }### Answer:
@Test public void testNPELayerBounds() throws IOException { MapLayer mapLayerBoundsNull = new MapLayer(new Layer() { public ReferencedEnvelope getBounds() { return null; } }); DefaultMapContext mapContext = new DefaultMapContext(DefaultGeographicCRS.WGS84); mapContext.addLayer(mapLayerBoundsNull); ReferencedEnvelope layerBounds = mapContext.getLayerBounds(); assertNull(layerBounds); ReferencedEnvelope maxBounds = mapContext.getMaxBounds(); assertNotNull(maxBounds); assertEquals( DefaultGeographicCRS.WGS84, maxBounds.getCoordinateReferenceSystem() ); assertTrue( maxBounds.isEmpty() ); }