@Test public void testVersion1() throws Throwable { PJsonObject layerJson = parseJSONObjectFromFile(MapfishStyleParserPluginTest.class, REQUEST_DATA_STYLE_JSON_V1_STYLE_JSON); Optional<Style> style = parser.parseStyle( null, new TestHttpClientFactory(), layerJson.getString("style")); assertTrue(style.isPresent()); transformer.transform(style.get()); final List<Rule> rules = new ArrayList<>(); style.get().accept(new AbstractStyleVisitor() { @Override public void visit(Rule rule) { rules.add(rule); } }); assertEquals(4, rules.size()); PointSymbolizer point = null; LineSymbolizer line = null; PolygonSymbolizer polygon = null; TextSymbolizer text = null; for (Rule rule: rules) { Filter geomSelectFunction = null; if (!(rule.getSymbolizers()[0] instanceof TextSymbolizer)) { assertTrue(rule.getFilter() instanceof And); And andFilter = (And) rule.getFilter(); assertEquals(2, andFilter.getChildren().size()); PropertyIsEqualTo filter = (PropertyIsEqualTo) andFilter.getChildren().get(0); PropertyName propertyName = (PropertyName) filter.getExpression1(); assertEquals("_gx_style", propertyName.getPropertyName()); Literal valueExpression = (Literal) filter.getExpression2(); assertEquals("1", valueExpression.getValue()); geomSelectFunction = andFilter.getChildren().get(1); } final List<Symbolizer> symbolizers = rule.symbolizers(); assertEquals(1, symbolizers.size()); for (Symbolizer symbolizer: symbolizers) { if (symbolizer instanceof PointSymbolizer) { assertEquals("1_Point", rule.getName()); assertNull(point); point = (PointSymbolizer) symbolizer; assertFilter(geomSelectFunction, Point.class, MultiPoint.class, GeometryCollection.class); } else if (symbolizer instanceof LineSymbolizer) { assertEquals("1_LineString", rule.getName()); assertNull(line); line = (LineSymbolizer) symbolizer; assertFilter(geomSelectFunction, LineString.class, LinearRing.class, MultiLineString.class, GeometryCollection.class); } else if (symbolizer instanceof PolygonSymbolizer) { assertEquals("1_Polygon", rule.getName()); assertNull(polygon); polygon = (PolygonSymbolizer) symbolizer; assertFilter(geomSelectFunction, Polygon.class, MultiPolygon.class, GeometryCollection.class); } else if (symbolizer instanceof TextSymbolizer) { assertEquals("1_Text", rule.getName()); assertNull(text); text = (TextSymbolizer) symbolizer; } else { fail(symbolizer + " was unexpected"); } } } assertNotNull(point); assertNotNull(line); assertNotNull(polygon); assertNotNull(text); }
@Override public Optional<Style> parseStyle( @Nullable final Configuration configuration, @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory, @Nonnull final String styleString) { final Optional<Style> styleOptional = tryParse( configuration, styleString, clientHttpRequestFactory); if (styleOptional.isPresent()) { return styleOptional; } return ParserPluginUtils.loadStyleAsURI( clientHttpRequestFactory, styleString, (final byte[] input) -> { try { return tryParse( configuration, new String(input, Constants.DEFAULT_CHARSET), clientHttpRequestFactory); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }); }
MapfishStyleParserPlugin implements StyleParserPlugin { @Override public Optional<Style> parseStyle( @Nullable final Configuration configuration, @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory, @Nonnull final String styleString) { final Optional<Style> styleOptional = tryParse( configuration, styleString, clientHttpRequestFactory); if (styleOptional.isPresent()) { return styleOptional; } return ParserPluginUtils.loadStyleAsURI( clientHttpRequestFactory, styleString, (final byte[] input) -> { try { return tryParse( configuration, new String(input, Constants.DEFAULT_CHARSET), clientHttpRequestFactory); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }); } }
MapfishStyleParserPlugin implements StyleParserPlugin { @Override public Optional<Style> parseStyle( @Nullable final Configuration configuration, @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory, @Nonnull final String styleString) { final Optional<Style> styleOptional = tryParse( configuration, styleString, clientHttpRequestFactory); if (styleOptional.isPresent()) { return styleOptional; } return ParserPluginUtils.loadStyleAsURI( clientHttpRequestFactory, styleString, (final byte[] input) -> { try { return tryParse( configuration, new String(input, Constants.DEFAULT_CHARSET), clientHttpRequestFactory); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }); }  }
MapfishStyleParserPlugin implements StyleParserPlugin { @Override public Optional<Style> parseStyle( @Nullable final Configuration configuration, @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory, @Nonnull final String styleString) { final Optional<Style> styleOptional = tryParse( configuration, styleString, clientHttpRequestFactory); if (styleOptional.isPresent()) { return styleOptional; } return ParserPluginUtils.loadStyleAsURI( clientHttpRequestFactory, styleString, (final byte[] input) -> { try { return tryParse( configuration, new String(input, Constants.DEFAULT_CHARSET), clientHttpRequestFactory); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }); }  @Override Optional<Style> parseStyle(
            @Nullable final Configuration configuration,
            @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory,
            @Nonnull final String styleString); }
MapfishStyleParserPlugin implements StyleParserPlugin { @Override public Optional<Style> parseStyle( @Nullable final Configuration configuration, @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory, @Nonnull final String styleString) { final Optional<Style> styleOptional = tryParse( configuration, styleString, clientHttpRequestFactory); if (styleOptional.isPresent()) { return styleOptional; } return ParserPluginUtils.loadStyleAsURI( clientHttpRequestFactory, styleString, (final byte[] input) -> { try { return tryParse( configuration, new String(input, Constants.DEFAULT_CHARSET), clientHttpRequestFactory); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }); }  @Override Optional<Style> parseStyle(
            @Nullable final Configuration configuration,
            @Nonnull final ClientHttpRequestFactory clientHttpRequestFactory,
            @Nonnull final String styleString);  }