private void loadGridSets() { if (getGwcConfig().getGridSets() != null) { this.gridSets = getGwcConfig() .getGridSets() .stream() .map( (xmlGridSet) -> { if (log.isDebugEnabled()) { log.debug("Reading " + xmlGridSet.getName()); } GridSet gridSet = xmlGridSet.makeGridSet(); log.info("Read GridSet " + gridSet.getName()); return gridSet; }) .collect( Collectors.toMap( GridSet::getName, Function.identity(), (GridSet x, GridSet y) -> { throw new IllegalStateException( "Gridsets with duplicate name " + x.getName()); }, HashMap::new)); } }
public void testModifyGridsetTruncates() throws Exception { final String oldName = "EPSG:4326"; final String newName = "MyEPSG:4326"; final GridSet oldGridset = gridSetBroker.get(oldName); final GridSet newGridset; { XMLGridSet xmlGridSet = new XMLGridSet(oldGridset); xmlGridSet.setName(newName); // make it so the gridset forces truncation xmlGridSet.setAlignTopLeft(!xmlGridSet.getAlignTopLeft()); newGridset = xmlGridSet.makeGridSet(); } XMLConfiguration xmlConfig = mock(XMLConfiguration.class); mediator = spy(mediator); when(mediator.getXmlConfiguration()).thenReturn(xmlConfig); when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); mediator.modifyGridSet(oldName, newGridset); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq(oldName)); verify(storageBroker, times(1)) .deleteByGridSetId(eq(tileLayerGroup.getName()), eq(oldName)); }
newGridset = xmlGridSet.makeGridSet(); gridSetBroker.put(newGridset);
return (T) ((XMLGridSet) object).makeGridSet();
public void testModifyGridsetNoNeedToTruncate() throws Exception { final String oldName = "EPSG:4326"; final String newName = "MyEPSG:4326"; final GridSet oldGridset = gridSetBroker.get(oldName); final GridSet newGridset; { XMLGridSet xmlGridSet = new XMLGridSet(oldGridset); xmlGridSet.setName(newName); newGridset = xmlGridSet.makeGridSet(); } XMLConfiguration xmlConfig = mock(XMLConfiguration.class); mediator = spy(mediator); when(mediator.getXmlConfiguration()).thenReturn(xmlConfig); assertNotNull(tileLayer.getGridSubset(oldName)); assertNotNull(tileLayerGroup.getGridSubset(oldName)); when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); mediator.modifyGridSet(oldName, newGridset); assertNull(tileLayer.getGridSubset(oldName)); assertNull(tileLayerGroup.getGridSubset(oldName)); assertNotNull(tileLayer.getGridSubset(newName)); assertNotNull(tileLayerGroup.getGridSubset(newName)); verify(xmlConfig, times(1)).removeGridset(eq(oldName)); verify(xmlConfig, times(1)).addOrReplaceGridSet(eq(new XMLGridSet(newGridset))); verify(xmlConfig, times(1)).save(); assertNull(gridSetBroker.get(oldName)); assertEquals(newGridset, gridSetBroker.get(newName)); verify(config, times(1)).save(); }