use of com.sldeditor.render.RuleRenderVisitor in project sldeditor by robward-scisys.
the class RuleRenderVisitorTest method testRuleRenderVisitor.
/**
* Test rule render visitor.
*/
@Test
public void testRuleRenderVisitor() {
StyledLayerDescriptor sld = createSLD();
StyledLayer styledLayer = sld.layers().get(0);
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
Style style = namedLayerImpl.styles().get(0);
FeatureTypeStyle ftsToRender = style.featureTypeStyles().get(0);
// Just find matching feature type style
int symbolIndex = 0;
RuleRenderVisitor visitor = new RuleRenderVisitor(ftsToRender, null, symbolIndex, new RuleRenderOptions());
style.accept(visitor);
Style copy = (Style) visitor.getCopy();
Rule ruleToRender = ftsToRender.rules().get(0);
Rule actualRule = copy.featureTypeStyles().get(0).rules().get(0);
// Filters should be null
assertNull(actualRule.getFilter());
assertEquals(ruleToRender.symbolizers(), actualRule.symbolizers());
// Now try and find 2nd rule, 2nd symbolizer
ruleToRender = ftsToRender.rules().get(1);
symbolIndex = 1;
visitor = new RuleRenderVisitor(ftsToRender, ruleToRender, symbolIndex, new RuleRenderOptions());
style.accept(visitor);
copy = (Style) visitor.getCopy();
assertEquals(1, copy.featureTypeStyles().get(0).rules().size());
actualRule = copy.featureTypeStyles().get(0).rules().get(0);
assertNull(actualRule.getFilter());
assertEquals(1, actualRule.symbolizers().size());
assertEquals(ruleToRender.symbolizers().get(1), actualRule.symbolizers().get(0));
}
}
Aggregations