use of org.geotools.styling.NamedLayer in project sldeditor by robward-scisys.
the class BatchUpdateFontUtilsTest method testContainsFonts.
/**
* Test method for {@link com.sldeditor.tool.batchupdatefont.BatchUpdateFontUtils#containsFonts(com.sldeditor.common.SLDDataInterface)}.
*/
@Test
public void testContainsFonts() {
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
String expectedNameLayerValue = "named layer test value";
namedLayer.setName(expectedNameLayerValue);
Style style = DefaultSymbols.createNewStyle();
String expectedNameStyleValue = "style test value";
style.setName(expectedNameStyleValue);
namedLayer.addStyle(style);
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
String expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedRuleValue = "rule test value";
rule.setName(expectedRuleValue);
TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
String expectedNameValue = "symbolizer test value";
symbolizer.setName(expectedNameValue);
rule.symbolizers().add(DefaultSymbols.createDefaultPointSymbolizer());
fts.rules().add(rule);
sld.layers().add(namedLayer);
SLDWriterInterface sldWriter = SLDWriterFactory.createWriter(null);
String sldContents = sldWriter.encodeSLD(null, sld);
SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), sldContents);
// Empty sld
List<BatchUpdateFontData> actualList = BatchUpdateFontUtils.containsFonts(null);
assertNull(actualList);
// No fonts
actualList = BatchUpdateFontUtils.containsFonts(sldData);
assertNull(actualList);
// With textsymbolizer
rule.symbolizers().add(symbolizer);
sldContents = sldWriter.encodeSLD(null, sld);
sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), sldContents);
actualList = BatchUpdateFontUtils.containsFonts(sldData);
assertEquals(1, actualList.size());
assertEquals(rule.getName(), actualList.get(0).getRuleName());
}
Aggregations