private void mockTileLayerDispatcher() throws Exception { when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); when(tld.getConfiguration(eq(tileLayer.getName()))).thenReturn(config); when(tld.getConfiguration(eq(tileLayerGroup.getName()))).thenReturn(config); when(tld.getTileLayer(eq(tileLayer.getName()))).thenReturn(tileLayer); when(tld.getTileLayer(eq(tileLayerGroup.getName()))).thenReturn(tileLayerGroup); when(tld.getLayerNames()) .thenReturn(ImmutableSet.of(tileLayer.getName(), tileLayerGroup.getName())); Iterable<TileLayer> tileLayers = ImmutableList.of((TileLayer) tileLayer, (TileLayer) tileLayerGroup); when(tld.getLayerList()).thenReturn(tileLayers); when(tld.layerExists(eq(tileLayer.getName()))).thenReturn(true); when(tld.layerExists(eq(tileLayerGroup.getName()))).thenReturn(true); }
private GeoServerTileLayer mockTileLayer(String layerName, List<String> gridSetNames) throws Exception { GeoServerTileLayer tileLayer = mock(GeoServerTileLayer.class); when(tld.layerExists(eq(layerName))).thenReturn(true); when(tld.getTileLayer(eq(layerName))).thenReturn(tileLayer); when(tileLayer.getName()).thenReturn(layerName); when(tileLayer.isEnabled()).thenReturn(true); final MimeType mimeType1 = MimeType.createFromFormat("image/png"); final MimeType mimeType2 = MimeType.createFromFormat("image/jpeg"); when(tileLayer.getMimeTypes()).thenReturn(ImmutableList.of(mimeType1, mimeType2)); Map<String, GridSubset> subsets = Maps.newHashMap(); Multimap<SRS, GridSubset> bySrs = LinkedHashMultimap.create(); GridSetBroker broker = gridSetBroker; for (String gsetName : gridSetNames) { GridSet gridSet = broker.get(gsetName); XMLGridSubset xmlGridSubset = new XMLGridSubset(); String gridSetName = gridSet.getName(); xmlGridSubset.setGridSetName(gridSetName); GridSubset gridSubSet = xmlGridSubset.getGridSubSet(broker); subsets.put(gsetName, gridSubSet); bySrs.put(gridSet.getSrs(), gridSubSet); when(tileLayer.getGridSubset(eq(gsetName))).thenReturn(gridSubSet); } for (SRS srs : bySrs.keySet()) { List<GridSubset> list = ImmutableList.copyOf(bySrs.get(srs)); when(tileLayer.getGridSubsetsForSRS(eq(srs))).thenReturn(list); } when(tileLayer.getGridSubsets()).thenReturn(subsets.keySet()); // sanity check for (String gsetName : gridSetNames) { assertTrue(tileLayer.getGridSubsets().contains(gsetName)); assertNotNull(tileLayer.getGridSubset(gsetName)); } return tileLayer; }